<commit_before>{% load ndf_tags %}
{% load i18n %}
{% load cache %}
{% get_group_name groupid as group_name_tag %}
{% user_access_policy groupid request.user as user_access %}
{% get_attribute_value node.pk 'release_response' as resp_val %}
{% get_attribute_value node.pk 'thread_interaction_type' as thr_int_type %}
{% check_is_gstaff groupid request.user as is_gstaff %}
{% block head %}

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <script type="text/javascript" src="/static/ndf/bower_components/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" async></script> <!-- checked -->
  
  <!-- Scripts and stylesheets for SideComments -->
  <!-- <script type="text/javascript" src="/static/ndf/bower_components/side-comments/release/side-comments.js"></script> -->
  <!-- <link rel="stylesheet" type"text/css" href="/static/ndf/bower_components/side-comments/release/side-comments.css"> -->
  <!-- <link rel="stylesheet" type="text/css" href="/static/ndf/bower_components/side-comments/release/themes/default-theme.css"> -->

  {% if user.is_authenticated %}
    <!-- orgitdown! -->
    <script type="text/javascript" src="/static/ndf/orgitdown/jquery.orgitdown-foundation.js"></script>
    <!-- orgitdown! toolbar settings -->
    <script type="text/javascript" src="/static/ndf/orgitdown/skins/gstudio/set.js"></script>
    <!-- orgitdown! skin -->
    <link rel="stylesheet" type="text/css" href="/static/ndf/orgitdown/skins/gstudio/style.css" />

  {% endif %}

{% endblock %}


<div>
  <br/>
    {% if allow_to_comment %}
      <div onclick="createDiscussion()" id="create-discussion" data-id="{{ node.pk }}" class="button small" style="margin-bottom:0;">
        {% if thr_int_type %}
          {{thr_int_type}} {% if all_replies|length > 0 %}({{all_replies|length }}) {% endif %}
        {% else %}
          Comment  {% if all_replies|length > 0 %} ({{all_replies|length }}) {% endif %}
        {% endif %}
      </div>
    {% endif %}

  <div id="replies-area" style="overflow-x:auto;">

    <!-- populating replies -->

    {% for each_reply in all_replies %}
      {% if resp_val == True or is_gstaff or request.user.id == each_reply.userid %}
      <div style="margin-left:calc({{each_reply.level}} * 48px); {% if each_reply.level == 1 %}margin-top:25px;{% endif %}" class="disc-replies" data-reply-id="{{ each_reply.oid }}" data-priornode-id="{{ each_reply.prior_node }}">
        <div class="row"> 
          <div class="small-3 columns">
            <a class="text-center" href="{% url 'dashboard' each_reply.userid %}">
              <span class="align-center"><i class="fi-torso"></i></span>
              <label>{{ each_reply.username }}</label>
            </a>
          </div>
          <div class="small-9 columns">
            {% spaceless %}
            {{each_reply.HTMLcontent | safe }}
            {% endspaceless %}
          </div>

          {% for node in each_reply.collection_set  %}
            <div style="margin: 1em;">
              <br/>
              {% if node.status != "MODERATION" %}
              {{node.mime_type}}
              <a class="th" style="" href="{% url 'read_file' group_id node node.name %}">
                 {% if 'image' in node.mime_type  %}
                      <img style="height:100px;" src="{% url 'getFileThumbnail' group_id node.pk %}" />
                    {% endif %}
                <p>{{node.name}}</p>
              </a>  
              {% else %}
                <p>File is under moderation.<br><a href="/{{group_id}}/moderation/status/{{node.pk}}" target="_blank">Click here to check status</a></p>
              {% endif %}
            </div>
          {% endfor %}
        </div>

        <div class="row">
        {% if request.user.id == each_reply.userid or is_gstaff %}
          <div class="reply-btn small-2  small-text-left large-2 columns" data-userid="{{each_reply.userid}}" onclick="deleteReply($(this))">{% trans "Delete" %}</div>
        {% endif %}
          <div class='reply-btn  small-2 small-text-left large-2 columns' data-id='{{ each_reply.oid }}' onclick='openOrgEditor($(this))' data-org-content='{{ each_reply.ORGcontent }}'>
          {% trans "Reply" %}
          </div>
          <div class="small-12 large-6  columns"> <small>{{ each_reply.last_update }}</small> </div>
      </div>

      </div>
      {% endif %}

    {% endfor %}
    <!-- END of populating replies -->
  </div>

  <!-- orgitdown container -->
  <div id="org" style="" class="reveal-modal small" data-reveal>
    <!-- Reply : -->
    <textarea id="orgitdownreps" name="content_org" placeholder="{% trans 'Enter your reply text here.'%}"></textarea>
    <input data-id="{{ node.pk }}" type="button" value="Post"  class="button expand reply-button" onclick="addReply($(this))">
    {% if sg_type != "Event" %}
      <input type="file" id="uploaded-files" style="" value="" multiple>
    {% else %}
      <input type="file" id="uploaded-files" style="" value="" multiple class="hide">
    {% endif %}
    <input type="hidden" id="prior-node" style="visibility:hidden" value="">
    <!-- <input type="hidden" id="thd" style="visibility:hidden" value=""> -->
  </div>
  <!-- end of orgit down container -->

</div>

<script type="text/javascript">
  // for discussion tab
  // storing ndf_tags return values in JS variables
  var user_access = "{{ user_access }}"; // "allow" or "disallow"
  {% edit_policy groupid node request.user as status %}
  var edit_policy = "{{ status }}"; // "allow" or "disallow"
  var is_user_authenticated = {{ request.user.is_authenticated|lower }};
  // if( user_access == "allow" && edit_policy == "allow" )
  // { 
  //   $("#orgitdownreps").orgitdown(mySettings);
  // }
  {% if request.user.is_authenticated %}
    $("#orgitdownreps").orgitdown(mySettings);
  {% endif %}
  function createDiscussion()
  {
    if( user_access == "allow"){
    if( is_user_authenticated )
    {  
      {% if request.user.is_authenticated %}
        // ajax to create thread for first time.
        $.ajax({
          url: "{% url 'create_discussion' group_id node.pk %}",
          success: function(data){
            data = JSON.parse(data);
            if( (data[0] == "thread-created") || (data[0] == "Thread-exist") )
            {
                // $("#create-discussion").hide();
                // changing method to behave same as sub-reply button
                $("#create-discussion").attr("onclick", "openOrgEditor($(this))");
                $("#prior-node").val("{{ node.pk }}") // _id
                // $("input[data-id='{{ node.pk }}']").val("{{ node.pk }}") // _id
                
                $("#create-discussion").trigger("click");
              }
              // else if( data[0] == "Thread-exist" ){
              //   // alert(data)
              //   $("#create-discussion").hide();
              //   $("#prior-node").val("{{ node.pk }}") // _id         
              //   // changing method to behave same as sub-reply button   
              //   $("#create-discussion").attr("onclick", "openOrgEditor($(this))");
              //   $("create-discussion").trigger("click");
              // }
              else{ alert(data) }
            }//,
          // complete: function(){
            // $("#prior-node").val("") // removing _id
          // }
        });
        // --- END ajax and create thread for first time.
        {% endif %}
      }
      else
      {
        // alert("To start discussion you need to login and be the member of this group.");
        alert("{% trans 'Login to start discussion' %}");
      }
    }
  else{
        alert("Only group members can comment.");
  }
  }
  // --- END of createDiscussion()
  // function called by "Add Reply" and "Reply" buttons to open editor
  function openOrgEditor(sourceObj)
  {
    if( user_access == "allow"){
    if( is_user_authenticated )
    {
      var sourceObjDataId = $(sourceObj).attr("data-id"); // prior-node _id
      $("#prior-node").val(sourceObjDataId);
      
      // tempOrgObj = $("#org").clone(true, true);
      // console.log($(sourceObj));
      
      // $("#org").detach();
      
      // if( sourceObjDataId == "{{ node.pk }}")
      // {
      //   $('div[data-id="'+ sourceObjDataId +'"]').after(tempOrgObj);
      // }
      // else
      // {
      //   $tempPrior = $('div[data-id="'+ sourceObjDataId +'"]').parent();<commit_msg>Display appropriate alert msg if commenting is prevented<commit_after>{% load ndf_tags %}
{% load i18n %}
{% load cache %}
{% get_group_name groupid as group_name_tag %}
{% user_access_policy groupid request.user as user_access %}
{% get_attribute_value node.pk 'release_response' as resp_val %}
{% get_attribute_value node.pk 'thread_interaction_type' as thr_int_type %}
{% check_is_gstaff groupid request.user as is_gstaff %}
{% block head %}

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <script type="text/javascript" src="/static/ndf/bower_components/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" async></script> <!-- checked -->
  
  <!-- Scripts and stylesheets for SideComments -->
  <!-- <script type="text/javascript" src="/static/ndf/bower_components/side-comments/release/side-comments.js"></script> -->
  <!-- <link rel="stylesheet" type"text/css" href="/static/ndf/bower_components/side-comments/release/side-comments.css"> -->
  <!-- <link rel="stylesheet" type="text/css" href="/static/ndf/bower_components/side-comments/release/themes/default-theme.css"> -->

  {% if user.is_authenticated %}
    <!-- orgitdown! -->
    <script type="text/javascript" src="/static/ndf/orgitdown/jquery.orgitdown-foundation.js"></script>
    <!-- orgitdown! toolbar settings -->
    <script type="text/javascript" src="/static/ndf/orgitdown/skins/gstudio/set.js"></script>
    <!-- orgitdown! skin -->
    <link rel="stylesheet" type="text/css" href="/static/ndf/orgitdown/skins/gstudio/style.css" />

  {% endif %}

{% endblock %}


<div>
  <br/>
    {% if allow_to_comment %}
      <div onclick="createDiscussion()" id="create-discussion" data-id="{{ node.pk }}" class="button small" style="margin-bottom:0;">
        {% if thr_int_type %}
          {{thr_int_type}} {% if all_replies|length > 0 %}({{all_replies|length }}) {% endif %}
        {% else %}
          Comment  {% if all_replies|length > 0 %} ({{all_replies|length }}) {% endif %}
        {% endif %}
      </div>
    {% endif %}

  <div id="replies-area" style="overflow-x:auto;">

    <!-- populating replies -->

    {% for each_reply in all_replies %}
      {% if resp_val == True or is_gstaff or request.user.id == each_reply.userid %}
      <div style="margin-left:calc({{each_reply.level}} * 48px); {% if each_reply.level == 1 %}margin-top:25px;{% endif %}" class="disc-replies" data-reply-id="{{ each_reply.oid }}" data-priornode-id="{{ each_reply.prior_node }}">
        <div class="row"> 
          <div class="small-3 columns">
            <a class="text-center" href="{% url 'dashboard' each_reply.userid %}">
              <span class="align-center"><i class="fi-torso"></i></span>
              <label>{{ each_reply.username }}</label>
            </a>
          </div>
          <div class="small-9 columns">
            {% spaceless %}
            {{each_reply.HTMLcontent | safe }}
            {% endspaceless %}
          </div>

          {% for node in each_reply.collection_set  %}
            <div style="margin: 1em;">
              <br/>
              {% if node.status != "MODERATION" %}
              {{node.mime_type}}
              <a class="th" style="" href="{% url 'read_file' group_id node node.name %}">
                 {% if 'image' in node.mime_type  %}
                      <img style="height:100px;" src="{% url 'getFileThumbnail' group_id node.pk %}" />
                    {% endif %}
                <p>{{node.name}}</p>
              </a>  
              {% else %}
                <p>File is under moderation.<br><a href="/{{group_id}}/moderation/status/{{node.pk}}" target="_blank">Click here to check status</a></p>
              {% endif %}
            </div>
          {% endfor %}
        </div>

        <div class="row">
        {% if request.user.id == each_reply.userid or is_gstaff %}
          <div class="reply-btn small-2  small-text-left large-2 columns" data-userid="{{each_reply.userid}}" onclick="deleteReply($(this))">{% trans "Delete" %}</div>
        {% endif %}
          <div class='reply-btn  small-2 small-text-left large-2 columns' data-id='{{ each_reply.oid }}' onclick='openOrgEditor($(this))' data-org-content='{{ each_reply.ORGcontent }}'>
          {% trans "Reply" %}
          </div>
          <div class="small-12 large-6  columns"> <small>{{ each_reply.last_update }}</small> </div>
      </div>

      </div>
      {% endif %}

    {% endfor %}
    <!-- END of populating replies -->
  </div>

  <!-- orgitdown container -->
  <div id="org" style="" class="reveal-modal small" data-reveal>
    <!-- Reply : -->
    <textarea id="orgitdownreps" name="content_org" placeholder="{% trans 'Enter your reply text here.'%}"></textarea>
    <input data-id="{{ node.pk }}" type="button" value="Post"  class="button expand reply-button" onclick="addReply($(this))">
    {% if sg_type != "Event" %}
      <input type="file" id="uploaded-files" style="" value="" multiple>
    {% else %}
      <input type="file" id="uploaded-files" style="" value="" multiple class="hide">
    {% endif %}
    <input type="hidden" id="prior-node" style="visibility:hidden" value="">
    <!-- <input type="hidden" id="thd" style="visibility:hidden" value=""> -->
  </div>
  <!-- end of orgit down container -->

</div>

<script type="text/javascript">
  // for discussion tab
  // storing ndf_tags return values in JS variables
  var user_access = "{{ user_access }}"; // "allow" or "disallow"
  {% edit_policy groupid node request.user as status %}
  var edit_policy = "{{ status }}"; // "allow" or "disallow"
  var is_user_authenticated = {{ request.user.is_authenticated|lower }};
  // if( user_access == "allow" && edit_policy == "allow" )
  // { 
  //   $("#orgitdownreps").orgitdown(mySettings);
  // }
  {% if request.user.is_authenticated %}
    $("#orgitdownreps").orgitdown(mySettings);
  {% endif %}
  function createDiscussion()
  {
    if( is_user_authenticated){
      if( user_access == "allow" )
      {  
        // ajax to create thread for first time.
        $.ajax({
          url: "{% url 'create_discussion' group_id node.pk %}",
          success: function(data){
            data = JSON.parse(data);
            if( (data[0] == "thread-created") || (data[0] == "Thread-exist") )
            {
                // $("#create-discussion").hide();
                // changing method to behave same as sub-reply button
                $("#create-discussion").attr("onclick", "openOrgEditor($(this))");
                $("#prior-node").val("{{ node.pk }}") // _id
                // $("input[data-id='{{ node.pk }}']").val("{{ node.pk }}") // _id
                
                $("#create-discussion").trigger("click");
              }
              // else if( data[0] == "Thread-exist" ){
              //   // alert(data)
              //   $("#create-discussion").hide();
              //   $("#prior-node").val("{{ node.pk }}") // _id         
              //   // changing method to behave same as sub-reply button   
              //   $("#create-discussion").attr("onclick", "openOrgEditor($(this))");
              //   $("create-discussion").trigger("click");
              // }
              else{ alert(data) }
            }//,
          // complete: function(){
            // $("#prior-node").val("") // removing _id
          // }
        });
        // --- END ajax and create thread for first time.
      }
      else
      {
        // alert("To start discussion you need to login and be the member of this group.");
        alert("Only group members can comment.");
      }
    }
  else{
        alert("{% trans 'Login to start discussion' %}");
  }
  }
  // --- END of createDiscussion()
  // function called by "Add Reply" and "Reply" buttons to open editor
  function openOrgEditor(sourceObj)
  {
    if( user_access == "allow"){
    if( is_user_authenticated )
    {
      var sourceObjDataId = $(sourceObj).attr("data-id"); // prior-node _id
      $("#prior-node").val(sourceObjDataId);
      
      // tempOrgObj = $("#org").clone(true, true);
      // console.log($(sourceObj));
      
      // $("#org").detach();
      
      // if( sourceObjDataId == "{{ node.pk }}")
      // {
      //   $('div[data-id="'+ sourceObjDataId +'"]').after(tempOrgObj);
      // }
      // else
      // {
      //   $tempPrior = $('div[data-id="'+ sourceObjDataId +'"]').parent();
{'fraction_non_alphanumeric': 0.19132409177820267, 'fraction_numerical': 0.0032265774378585086, 'mean_word_length': 2.358819987959061, 'pattern_counts': {'":': 0, '<': 167, '<?xml version=': 0, '>': 171, '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': '4737365', 'n_tokens_mistral': 5477, 'n_tokens_neox': 5072, 'n_words': 1059}