<commit_before>{% load ndf_tags %}
{% load i18n %}
{% get_group_object groupid as group_object %}

    <div id="upload_picModal" class="processing-screen reveal-modal medium  radius" data-reveal data-alert>
        <div id="upload_picModalLabel" class="processing-screen-label"></div>
        <a class="close-reveal-modal">&#215;</a>
    </div>
       <div class="text-center">

        <div class="div-height">
          {% get_relation_value node.pk 'has_thumbnail' as grel_dict %}
          {% get_relation_value node.pk 'has_logo' as grel_dict_logo %}
          {% get_relation_value node.pk 'has_banner_pic' as grel_banner %}
          {% if prof_pic_obj %}
            <img src="{{MEDIA_URL}}{{prof_pic_obj.if_file.original.relurl}}" class="img-height"/>
          {% elif grel_dict %}
            <img src="{{MEDIA_URL}}{{grel_dict.grel_node.if_file.thumbnail.relurl}}" class="img-height"/>
          {% elif grel_dict_logo %}
            <img src="{{MEDIA_URL}}{{grel_dict_logo.grel_node.if_file.thumbnail.relurl}}" class="img-height"/>
            {% elif grel_banner %}
            <img src="{{MEDIA_URL}}{{grel_banner.grel_node.if_file.mid.relurl}}" class="img-height"/>
          {% else %}
              {% if "Author" in group_object.member_of_names_list %}
                  <i class="fi-torso style2 text-center"></i>
              {% elif node.if_file.mid.relurl %}
                   <img src="{{MEDIA_URL}}{{node.if_file.mid.relurl}}" alt="Profile picture for this group." class="img-height">
              {% elif "announced_unit" in  group_object.member_of_names_list %}
                    <img src="/static/ndf/images/maths-cover.png" alt="Profile picture for this group." class="img-height">
              {% else %}
                    <img src="/static/ndf/css/themes/{{site.SITE_NAME|lower}}/images/default-bg.png" alt="Profile picture for this group." class="img-height">
              {% endif %}
          {% endif %}
        </div>
        {% if not no_update_btn %}
        {% if request.user.is_authenticated %}
        {% check_is_gstaff groupid request.user as gstaff_access %}
        {% if "Author" in group_object.member_of_names_list and user_id == request.user.id or "Author" not in group_object.member_of_names_list and gstaff_access %}
                <div class="row" >
                  <div class="small-12 columns" >
                    <a data-reveal-id="{{widget_for}}_prof_pic_prop" class="button tiny expand margin-p5 btn-font" id="{{widget_for}}_btnUploadProfilePic">{% if prof_pic_obj %}Change{% else %}Upload{% endif %}</a>
                  </div>
                </div>
            {% endif %}
        {% endif %}
        {% endif %}
        </div>


            <div id="{{widget_for}}_prof_pic_prop" class="reveal-modal medium old-pics-data" data-reveal >
                <a id="{{widget_for}}_upload_photo">
                  <div id="upload-photo-div" class="text-center">
                    <label class="upload_photo_lbl fi-upload">Upload New Photo</label>
                  </div>
                </a>
                {% if old_profile_pics %}
                <fieldset id="{{widget_for}}_existing-photo-fieldset">
                    <legend class="choose_photo_lbl">Choose Any Existing Photo</legend>
                    <div class="existing-photo-div" >
                      {% for each_prof_pic in old_profile_pics %}
                        <div class="old_img">
                          <img src="{{MEDIA_URL}}{{each_prof_pic.if_file.mid.relurl}}" />
                          <div class="{{widget_for}}_prof_pic_select">
                          <input type="button" value="Use this" class="button tiny use_old_img_btn" onclick="update_img('{{each_prof_pic.pk}}')" />
                          </div>
                        </div>
                      {% endfor %}
                    </div>
                </fieldset>
                {% endif %}
                <div id="{{widget_for}}_pic_div" class="hide row">
                    <form class="dropzone" id ="{{widget_for}}_docPost" enctype="multipart/form-data" method="post"  action="{% url 'upload_prof_pic' group_id %}">
                        {% csrf_token %}
                        <input type="file" name="filehive" id="{{widget_for}}_docFile" accept="image/*" class="hide" />
                        {% if is_banner and not is_profile %}
                          <input type="hidden" name="pic_rt" value="is_banner"></input>
                        {% elif  is_profile and not is_banner %}
                          <input type="hidden" name="pic_rt" value="is_profile"></input>
                        {% elif is_banner  %}
                          <input type="hidden" name="pic_rt" value="is_banner"></input>
                        {% elif  is_thumbnail and not is_banner or is_profile %}
                          <input type="hidden" name="pic_rt" value="is_thumbnail"></input>
                          <input type="hidden" name="node_id" value="{{node_id}}"></input>

                        {% endif %}

                        <div class="{{widget_for}}_upload_cancel_div">
                            <img id="{{widget_for}}_img_preview" src="" alt="New profile photo" />
                            <input type="submit" id="{{widget_for}}_submitpostid" value="Save" class="button tiny margin-p5 submit-btn" />
                            <input type="button" class="button tiny margin-p5" id="{{widget_for}}_btnUploadCancel" value="Cancel">
                        </div>
                        <input type="hidden" name="type" value="profile_pic">
                        <input type="hidden" name="user" value="{{usr}}">
                        {% if url_name %}
                        <input type="hidden" name="url_name" value="{{url_name}}">
                        {% endif %}

                    </form>
                </div>
                <p id="{{widget_for}}_message" style="display:none">
                  {% trans "Your profile photo is uploading. Please wait.." %}
                </p>

                <a class="close-reveal-modal">&#215;</a>
            </div>


<style type="text/css">
  div.reveal-modal > label {
    color: white;
    font-weight: bold;
    font-size: 1rem;
  }

  #upload-photo-div{
    height: 50px;
    border: 2px solid #0b8a91;
  }

  .choose_photo_lbl{
    color: #0b8a91;
  }

  .img-height {
      height: 100%;
  }

  .btn-font{
    font-size:15px !important;
  }

  .div-height {
      margin-bottom: 0.5em;
      height: 9em;
  }


  .upload_photo_lbl{
    color: #0b8a91;
    font-size:30px;
  }

  .old_img{
      border: 2px solid #0b8a91;
      display:inline-block;
      position:relative;
  }

  .use_old_img_btn{
      position:absolute;
      bottom:-19px;
      right:0px;
      display:none;
  }

  .existing-photo-div{
    display:inline-block;
    overflow-y: auto;
    height:320px;
  }
  .old_img > img{
    height:150px;
    width:100px;
  }

  .old-pics-data{
    height:500px;
  }

  .submit-btn{
    margin-left:2rem;
  }

</style>

<script type="text/javascript">
  // Hover events over old profile pics ---------------------------------------------------------
  $(".old_img")
    .mouseover(function(){
    $(this).find(".use_old_img_btn").css("display","block");
    })

    .mouseout(function(){
    $(this).find(".use_old_img_btn").css("display","none");
    })

  // Upload/Change Profile photo ----------------------------------------------------------------
  $(document).on('click','#{{widget_for}}_btnUploadProfilePic',function(){
    $("#{{widget_for}}_prof_pic_prop").foundation('reveal', 'open');
  });

  // Cancel/Abort Profile pic Upload-------------------------------------------------------------
  $(document).on('click','#{{widget_for}}_btnUploadCancel',function(){
    $("#{{widget_for}}_pic_div").addClass("hide");
    $("#{{widget_for}}_upload_photo").removeClass("hide");
    $("#{{widget_for}}_existing-photo-fieldset").removeClass("hide");
    $("#{{widget_for}}_docFile").val("");
  });

  // Upload photo btn in overlay ----------------------------------------------------------------
  $(document).on('click','#{{widget_for}}_upload_photo',function(){
    $("#{{widget_for}}_docFile").trigger("click");
    // $(this).addClass("hide")
    // $("#{{widget_for}}_existing-photo-fieldset").addClass("hide")
  })

  // Choose from already uploaded(old profile photos) files -------------------------------------
  function update_img(old_img_id){
    $('<input>')
      .attr('type','hidden')
      .attr('name','old_pic_ele')
      .attr('id','{{widget_for}}_old_pic_ele')
      .attr('value',old_img_id)
      .appendTo('form#{{widget_for}}_docPost');
    $("#{{widget_for}}_submitpostid").trigger("click");
  }


  //Upload file action validation ---------------------------------------------------------------
  $(document).on('change','#{{widget_for}}_docFile',function(){
    $("#{{widget_for}}_upload_photo").addClass("hide")
    $("#{{widget_for}}_existing-photo-fieldset").addClass("hide")
    $("#{{widget_for}}_pic_div").removeClass("hide");
    file_mime_type = this.files[0].type;
    if(file_mime_type.indexOf("image/") < 0){
      $("#{{widget_for}}_btnUploadCancel").click()
      var message = "{% trans 'Only image files should be selected for setting your profile picture!' %}"
      $("#upload_picModalLabel").text(message);
      $("#upload_picModal").addClass("alert");
      $("#upload_picModal").foundation('reveal', 'open');
    }
    else{
      //$('#txtSelectedFiles').val(this.value);
      var reader = new FileReader();
      reader.onload = function (e) {
        $('#{{widget_for}}_img_preview')
          .attr('src', e.target.result)
          .width(150)
          .height(200)
          .removeClass("hide");
        };
      reader.readAsDataURL(this.files[0]);
    }
  });

  // Update profile photo -----------------------------------------------------------------------
  $(document).on('click','#{{widget_for}}_submitpostid',function(){
    upload_from_existing = $("#{{widget_for}}_old_pic_ele").length
    if($("#{{widget_for}}_docFile").val() != "" || upload_from_existing > 0) {
      $("#{{widget_for}}_prof_pic_prop").foundation('reveal', 'close');
      $("#{{widget_for}}_message").show();
      $(".{{widget_for}}_upload_cancel_div").addClass("hide");
      $("#{{widget_for}}_btnUploadProfilePic").attr("disabled", "disabled");
      var message = "{% trans 'Please wait while your profile picture is updated..' %}"
      $("#upload_picModalLabel").text(message);
      $("#upload_picModal").addClass("success");
      $("#upload_picModal").foundation('reveal', 'open');
    }
    else {
      var message = "{% trans 'Please select an image to set it as a profile picture !' %}"
      $("#upload_picModalLabel").text(message);
      $("#upload_picModal").addClass("warning");
      $("#upload_picModal").foundation('reveal', 'open');
      $("#{{widget_for}}_btnUploadCancel").click();
      return false;
    }
  });

  // Reveal modal close event -------------------------------------------------------------------
  $(document).on('closed.fndtn.reveal', '.reveal-modal', function () {
    $(this).removeClass("success").removeClass("alert").removeClass("warning");
  });

</script>
<commit_msg>REndering original image in banner pic instead of mid from widget_photo_upload<commit_after>{% load ndf_tags %}
{% load i18n %}
{% get_group_object groupid as group_object %}

    <div id="upload_picModal" class="processing-screen reveal-modal medium  radius" data-reveal data-alert>
        <div id="upload_picModalLabel" class="processing-screen-label"></div>
        <a class="close-reveal-modal">&#215;</a>
    </div>
       <div class="text-center">

        <div class="div-height">
          {% get_relation_value node.pk 'has_thumbnail' as grel_dict %}
          {% get_relation_value node.pk 'has_logo' as grel_dict_logo %}
          {% get_relation_value node.pk 'has_banner_pic' as grel_banner %}
          {% if prof_pic_obj %}
            <img src="{{MEDIA_URL}}{{prof_pic_obj.if_file.original.relurl}}" class="img-height"/>
          {% elif grel_dict %}
            <img src="{{MEDIA_URL}}{{grel_dict.grel_node.if_file.thumbnail.relurl}}" class="img-height"/>
          {% elif grel_dict_logo %}
            <img src="{{MEDIA_URL}}{{grel_dict_logo.grel_node.if_file.thumbnail.relurl}}" class="img-height"/>
            {% elif grel_banner %}
            <img src="{{MEDIA_URL}}{{grel_banner.grel_node.if_file.original.relurl}}" class="img-height"/>
          {% else %}
              {% if "Author" in group_object.member_of_names_list %}
                  <i class="fi-torso style2 text-center"></i>
              {% elif node.if_file.mid.relurl %}
                   <img src="{{MEDIA_URL}}{{node.if_file.mid.relurl}}" alt="Profile picture for this group." class="img-height">
              {% elif "announced_unit" in  group_object.member_of_names_list %}
                    <img src="/static/ndf/images/maths-cover.png" alt="Profile picture for this group." class="img-height">
              {% else %}
                    <img src="/static/ndf/css/themes/{{site.SITE_NAME|lower}}/images/default-bg.png" alt="Profile picture for this group." class="img-height">
              {% endif %}
          {% endif %}
        </div>
        {% if not no_update_btn %}
        {% if request.user.is_authenticated %}
        {% check_is_gstaff groupid request.user as gstaff_access %}
        {% if "Author" in group_object.member_of_names_list and user_id == request.user.id or "Author" not in group_object.member_of_names_list and gstaff_access %}
                <div class="row" >
                  <div class="small-12 columns" >
                    <a data-reveal-id="{{widget_for}}_prof_pic_prop" class="button tiny expand margin-p5 btn-font" id="{{widget_for}}_btnUploadProfilePic">{% if prof_pic_obj %}Change{% else %}Upload{% endif %}</a>
                  </div>
                </div>
            {% endif %}
        {% endif %}
        {% endif %}
        </div>


            <div id="{{widget_for}}_prof_pic_prop" class="reveal-modal medium old-pics-data" data-reveal >
                <a id="{{widget_for}}_upload_photo">
                  <div id="upload-photo-div" class="text-center">
                    <label class="upload_photo_lbl fi-upload">Upload New Photo</label>
                  </div>
                </a>
                {% if old_profile_pics %}
                <fieldset id="{{widget_for}}_existing-photo-fieldset">
                    <legend class="choose_photo_lbl">Choose Any Existing Photo</legend>
                    <div class="existing-photo-div" >
                      {% for each_prof_pic in old_profile_pics %}
                        <div class="old_img">
                          <img src="{{MEDIA_URL}}{{each_prof_pic.if_file.mid.relurl}}" />
                          <div class="{{widget_for}}_prof_pic_select">
                          <input type="button" value="Use this" class="button tiny use_old_img_btn" onclick="update_img('{{each_prof_pic.pk}}')" />
                          </div>
                        </div>
                      {% endfor %}
                    </div>
                </fieldset>
                {% endif %}
                <div id="{{widget_for}}_pic_div" class="hide row">
                    <form class="dropzone" id ="{{widget_for}}_docPost" enctype="multipart/form-data" method="post"  action="{% url 'upload_prof_pic' group_id %}">
                        {% csrf_token %}
                        <input type="file" name="filehive" id="{{widget_for}}_docFile" accept="image/*" class="hide" />
                        {% if is_banner and not is_profile %}
                          <input type="hidden" name="pic_rt" value="is_banner"></input>
                        {% elif  is_profile and not is_banner %}
                          <input type="hidden" name="pic_rt" value="is_profile"></input>
                        {% elif is_banner  %}
                          <input type="hidden" name="pic_rt" value="is_banner"></input>
                        {% elif  is_thumbnail and not is_banner or is_profile %}
                          <input type="hidden" name="pic_rt" value="is_thumbnail"></input>
                          <input type="hidden" name="node_id" value="{{node_id}}"></input>

                        {% endif %}

                        <div class="{{widget_for}}_upload_cancel_div">
                            <img id="{{widget_for}}_img_preview" src="" alt="New profile photo" />
                            <input type="submit" id="{{widget_for}}_submitpostid" value="Save" class="button tiny margin-p5 submit-btn" />
                            <input type="button" class="button tiny margin-p5" id="{{widget_for}}_btnUploadCancel" value="Cancel">
                        </div>
                        <input type="hidden" name="type" value="profile_pic">
                        <input type="hidden" name="user" value="{{usr}}">
                        {% if url_name %}
                        <input type="hidden" name="url_name" value="{{url_name}}">
                        {% endif %}

                    </form>
                </div>
                <p id="{{widget_for}}_message" style="display:none">
                  {% trans "Your profile photo is uploading. Please wait.." %}
                </p>

                <a class="close-reveal-modal">&#215;</a>
            </div>


<style type="text/css">
  div.reveal-modal > label {
    color: white;
    font-weight: bold;
    font-size: 1rem;
  }

  #upload-photo-div{
    height: 50px;
    border: 2px solid #0b8a91;
  }

  .choose_photo_lbl{
    color: #0b8a91;
  }

  .img-height {
      height: 100%;
  }

  .btn-font{
    font-size:15px !important;
  }

  .div-height {
      margin-bottom: 0.5em;
      height: 9em;
  }


  .upload_photo_lbl{
    color: #0b8a91;
    font-size:30px;
  }

  .old_img{
      border: 2px solid #0b8a91;
      display:inline-block;
      position:relative;
  }

  .use_old_img_btn{
      position:absolute;
      bottom:-19px;
      right:0px;
      display:none;
  }

  .existing-photo-div{
    display:inline-block;
    overflow-y: auto;
    height:320px;
  }
  .old_img > img{
    height:150px;
    width:100px;
  }

  .old-pics-data{
    height:500px;
  }

  .submit-btn{
    margin-left:2rem;
  }

</style>

<script type="text/javascript">
  // Hover events over old profile pics ---------------------------------------------------------
  $(".old_img")
    .mouseover(function(){
    $(this).find(".use_old_img_btn").css("display","block");
    })

    .mouseout(function(){
    $(this).find(".use_old_img_btn").css("display","none");
    })

  // Upload/Change Profile photo ----------------------------------------------------------------
  $(document).on('click','#{{widget_for}}_btnUploadProfilePic',function(){
    $("#{{widget_for}}_prof_pic_prop").foundation('reveal', 'open');
  });

  // Cancel/Abort Profile pic Upload-------------------------------------------------------------
  $(document).on('click','#{{widget_for}}_btnUploadCancel',function(){
    $("#{{widget_for}}_pic_div").addClass("hide");
    $("#{{widget_for}}_upload_photo").removeClass("hide");
    $("#{{widget_for}}_existing-photo-fieldset").removeClass("hide");
    $("#{{widget_for}}_docFile").val("");
  });

  // Upload photo btn in overlay ----------------------------------------------------------------
  $(document).on('click','#{{widget_for}}_upload_photo',function(){
    $("#{{widget_for}}_docFile").trigger("click");
    // $(this).addClass("hide")
    // $("#{{widget_for}}_existing-photo-fieldset").addClass("hide")
  })

  // Choose from already uploaded(old profile photos) files -------------------------------------
  function update_img(old_img_id){
    $('<input>')
      .attr('type','hidden')
      .attr('name','old_pic_ele')
      .attr('id','{{widget_for}}_old_pic_ele')
      .attr('value',old_img_id)
      .appendTo('form#{{widget_for}}_docPost');
    $("#{{widget_for}}_submitpostid").trigger("click");
  }


  //Upload file action validation ---------------------------------------------------------------
  $(document).on('change','#{{widget_for}}_docFile',function(){
    $("#{{widget_for}}_upload_photo").addClass("hide")
    $("#{{widget_for}}_existing-photo-fieldset").addClass("hide")
    $("#{{widget_for}}_pic_div").removeClass("hide");
    file_mime_type = this.files[0].type;
    if(file_mime_type.indexOf("image/") < 0){
      $("#{{widget_for}}_btnUploadCancel").click()
      var message = "{% trans 'Only image files should be selected for setting your profile picture!' %}"
      $("#upload_picModalLabel").text(message);
      $("#upload_picModal").addClass("alert");
      $("#upload_picModal").foundation('reveal', 'open');
    }
    else{
      //$('#txtSelectedFiles').val(this.value);
      var reader = new FileReader();
      reader.onload = function (e) {
        $('#{{widget_for}}_img_preview')
          .attr('src', e.target.result)
          .width(150)
          .height(200)
          .removeClass("hide");
        };
      reader.readAsDataURL(this.files[0]);
    }
  });

  // Update profile photo -----------------------------------------------------------------------
  $(document).on('click','#{{widget_for}}_submitpostid',function(){
    upload_from_existing = $("#{{widget_for}}_old_pic_ele").length
    if($("#{{widget_for}}_docFile").val() != "" || upload_from_existing > 0) {
      $("#{{widget_for}}_prof_pic_prop").foundation('reveal', 'close');
      $("#{{widget_for}}_message").show();
      $(".{{widget_for}}_upload_cancel_div").addClass("hide");
      $("#{{widget_for}}_btnUploadProfilePic").attr("disabled", "disabled");
      var message = "{% trans 'Please wait while your profile picture is updated..' %}"
      $("#upload_picModalLabel").text(message);
      $("#upload_picModal").addClass("success");
      $("#upload_picModal").foundation('reveal', 'open');
    }
    else {
      var message = "{% trans 'Please select an image to set it as a profile picture !' %}"
      $("#upload_picModalLabel").text(message);
      $("#upload_picModal").addClass("warning");
      $("#upload_picModal").foundation('reveal', 'open');
      $("#{{widget_for}}_btnUploadCancel").click();
      return false;
    }
  });

  // Reveal modal close event -------------------------------------------------------------------
  $(document).on('closed.fndtn.reveal', '.reveal-modal', function () {
    $(this).removeClass("success").removeClass("alert").removeClass("warning");
  });

</script>

{'fraction_non_alphanumeric': 0.20756880733944955, 'fraction_numerical': 0.006263232180663374, 'mean_word_length': 2.071805988348462, 'pattern_counts': {'":': 0, '<': 159, '<?xml version=': 0, '>': 163, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '16076', 'n_tokens_mistral': 6890, 'n_tokens_neox': 6495, 'n_words': 1104}