<commit_before><%
  group = _ob.get(:Group, _get["group_id"])
  
  if _get["choice"] == "add_reporter"
    show_reporters = _ob.list(:Reporter) - group.reporters
    show_reporters.each do |reporter|
      %>
        <div>
          <a href="javascript: group_view_add_reporter('<%=reporter.id%>');"><%=reporter.name.html%></a>
        </div>
      <%
    end
    
    exit
  end
  
  if _get["choice"] == "save_reporter"
    reporter = _ob.get(:Reporter, _get["reporter_id"])
    group.add_reporter(reporter)
    exit
  end
  
  if _get["choice"] == "remove_reporter"
    reporter = _ob.get(:Reporter, _get["reporter_id"])
    group.remove_reporter(reporter)
    exit
  end
  
  print _site.header(sprintf(_("View group: %s"), group.name))
%>

<div style="padding-bottom: 15px;">
  <input type="button" value="<%=_"Edit group"%>" onclick="location.href='/?s=group_edit&amp;group_id=<%=group.id%>';" />
</div>

<%=_site.boxt(_("Services"), 350)%>
  <div style="padding-bottom: 15px;">
    <input type="button" value="<%=_"Add service"%>" onclick="location.href='/?s=service_edit&amp;group_id=<%=group.id%>';" />
  </div>
  
  <table class="list">
    <thead>
      <tr>
        <th><%=_"Service"%></th>
      </tr>
    </thead>
    <tbody>
      <%
        services = group.services
        
        services.each do |service|
          %>
            <tr>
              <td>
                <%=service.html%>
              </td>
            </tr>
          <%
        end
        
        if services.empty?
          %>
            <tr>
              <td colspan="1" class="error">
                <%=_"No services were found."%>
              </td>
            </tr>
          <%
        end
      %>
    </tbody>
  </table>
<%=_site.boxb%>

<br />

<%=_site.boxt(_("Reporters"), 350)%>
  <div style="padding-bottom: 15px;">
    <input type="button" value="<%=_"Add reporter"%>" onclick="modal({title: '<%=_"Add reporter"%>', url: '/clean.rhtml?s=group_view&amp;choice=add_reporter&amp;group_id=<%=group.id%>'});" />
  </div>
  
  <table class="list">
    <thead>
      <tr>
        <th><%=_"Reporter"%></th>
        <th><%=_"Actions"%></th>
      </tr>
    </thead>
    <tbody>
      <%
        reporters = group.reporters
        
        reporters.each do |reporter|
          %>
            <tr>
              <td>
                <%=reporter.html%>
              </td>
              <td>
                (<a href="javascript: if (confirm('<%=_"Do you want to remove this reporter?"%>')){group_remove_reporter('<%=reporter.id%>');}"><%=_"remove"%></a>)
              </td>
            </tr>
          <%
        end
        
        if reporters.empty?
          %>
            <tr>
              <td colspan="2" class="error">
                <%=_"No reporters has been added to this group."%>
              </td>
            </tr>
          <%
        end
      %>
    </tbody>
  </table>
<%=_site.boxb%>

<script type="text/javascript">
  function group_view_add_reporter(reporter_id){
    $.ajax({type: "GET", url: "/clean.rhtml?s=group_view&choice=save_reporter&group_id=<%=group.id%>&reporter_id=" + reporter_id, cache: false, async: true, complete: function(data){
      if (data.responseText.length > 0){
        alert(data.responseText);
      }
      
      location.reload();
    }});
  }
  
  function group_remove_reporter(reporter_id){
    $.ajax({type: "GET", url: "/clean.rhtml?s=group_view&choice=remove_reporter&group_id=<%=group.id%>&reporter_id=" + reporter_id, cache: false, async: true, complete: function(data){
      if (data.responseText.length > 0){
        alert(data.responseText);
      }
      
      location.reload();
    }});
  }
</script><commit_msg>Now sorting services by name.<commit_after><%
  group = _ob.get(:Group, _get["group_id"])
  
  if _get["choice"] == "add_reporter"
    show_reporters = _ob.list(:Reporter) - group.reporters
    show_reporters.each do |reporter|
      %>
        <div>
          <a href="javascript: group_view_add_reporter('<%=reporter.id%>');"><%=reporter.name.html%></a>
        </div>
      <%
    end
    
    exit
  end
  
  if _get["choice"] == "save_reporter"
    reporter = _ob.get(:Reporter, _get["reporter_id"])
    group.add_reporter(reporter)
    exit
  end
  
  if _get["choice"] == "remove_reporter"
    reporter = _ob.get(:Reporter, _get["reporter_id"])
    group.remove_reporter(reporter)
    exit
  end
  
  print _site.header(sprintf(_("View group: %s"), group.name))
%>

<div style="padding-bottom: 15px;">
  <input type="button" value="<%=_"Edit group"%>" onclick="location.href='/?s=group_edit&amp;group_id=<%=group.id%>';" />
</div>

<%=_site.boxt(_("Services"), 350)%>
  <div style="padding-bottom: 15px;">
    <input type="button" value="<%=_"Add service"%>" onclick="location.href='/?s=service_edit&amp;group_id=<%=group.id%>';" />
  </div>
  
  <table class="list">
    <thead>
      <tr>
        <th><%=_"Service"%></th>
      </tr>
    </thead>
    <tbody>
      <%
        services = group.services("orderby" => "name")
        
        services.each do |service|
          %>
            <tr>
              <td>
                <%=service.html%>
              </td>
            </tr>
          <%
        end
        
        if services.empty?
          %>
            <tr>
              <td colspan="1" class="error">
                <%=_"No services were found."%>
              </td>
            </tr>
          <%
        end
      %>
    </tbody>
  </table>
<%=_site.boxb%>

<br />

<%=_site.boxt(_("Reporters"), 350)%>
  <div style="padding-bottom: 15px;">
    <input type="button" value="<%=_"Add reporter"%>" onclick="modal({title: '<%=_"Add reporter"%>', url: '/clean.rhtml?s=group_view&amp;choice=add_reporter&amp;group_id=<%=group.id%>'});" />
  </div>
  
  <table class="list">
    <thead>
      <tr>
        <th><%=_"Reporter"%></th>
        <th><%=_"Actions"%></th>
      </tr>
    </thead>
    <tbody>
      <%
        reporters = group.reporters
        
        reporters.each do |reporter|
          %>
            <tr>
              <td>
                <%=reporter.html%>
              </td>
              <td>
                (<a href="javascript: if (confirm('<%=_"Do you want to remove this reporter?"%>')){group_remove_reporter('<%=reporter.id%>');}"><%=_"remove"%></a>)
              </td>
            </tr>
          <%
        end
        
        if reporters.empty?
          %>
            <tr>
              <td colspan="2" class="error">
                <%=_"No reporters has been added to this group."%>
              </td>
            </tr>
          <%
        end
      %>
    </tbody>
  </table>
<%=_site.boxb%>

<script type="text/javascript">
  function group_view_add_reporter(reporter_id){
    $.ajax({type: "GET", url: "/clean.rhtml?s=group_view&choice=save_reporter&group_id=<%=group.id%>&reporter_id=" + reporter_id, cache: false, async: true, complete: function(data){
      if (data.responseText.length > 0){
        alert(data.responseText);
      }
      
      location.reload();
    }});
  }
  
  function group_remove_reporter(reporter_id){
    $.ajax({type: "GET", url: "/clean.rhtml?s=group_view&choice=remove_reporter&group_id=<%=group.id%>&reporter_id=" + reporter_id, cache: false, async: true, complete: function(data){
      if (data.responseText.length > 0){
        alert(data.responseText);
      }
      
      location.reload();
    }});
  }
</script>
{'fraction_non_alphanumeric': 0.19126566922765872, 'fraction_numerical': 0.004313249764119153, 'mean_word_length': 2.107202680067002, 'pattern_counts': {'":': 0, '<': 185, '<?xml version=': 0, '>': 190, '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': '2094252', 'n_tokens_mistral': 2635, 'n_tokens_neox': 2535, 'n_words': 416}