<commit_before><h2>
  Partner Advertisements for Topic: <%= SignUpTopic.find(params[:id]).topic_name %>
</h2>

<table class="general">
  <tr>
    <th width="500">Team Name</th>
    <th width="500">Members</th>
    <th width="500">Desired Qualifications</th>
    <th width="500">Action</th>
  </tr>

  <% requestors = [] %>
  <% requestors_names = [] %>

  <%# @results is the ad_info for an assignment's topic %>
  <% @results.each {|result| %>

    <%# Create a list of hashed requestors which have asked to join the team %>
    <% 
      @join_team_requests = JoinTeamRequest.where(team_id: result[:team_id])
      @join_team_requests.each do |join_team_request|
        if join_team_request.status=='P'
          requestors_names << User.find(Participant.find(join_team_request.participant_id).user_id).name
          requestors << {name: User.find(Participant.find(join_team_request.participant_id).user_id).name, request_id: join_team_request.id}
        end
      end 
    %>

    <%
      team_members = []
      TeamsUser.where(team_id: result[:team_id]).each{|teamuser|
        team_members << User.find(teamuser.user_id).name
      }
      if result[:advertise_for_partner]|| result[:advertise_for_partner] == 1
    %>
      <tr>
        <td align="center" width="500"><%= result[:name] %></td>
        <td align="center" width="500"><%= team_members.join(', ') %></td>
        <td align="center" width="500"><%= result[:comments_for_advertisement] %></td>
        <% if  Participant.where(parent_id: result[:assignment_id], user_id: session[:user].id).first && !team_members.include?(session[:user].name) && !requestors_names.include?(session[:user].name) %>
          <td align="center"><%= link_to "Request invitation", :controller => 'join_team_requests', :action => 'new',
            :assignment_id=>result[:assignment_id],
            :topic_id=>result[:topic_id],
            :team_id=>result[:team_id]
          %>
          <img src="/assets/info.png" title="Send request to join this team">
          </td>
        <% else %>
          <% if team_members.include?(session[:user].name) %>
            <td align="center"><img src="/assets/info.png" title="You're a member of this team and cannot request to join!"></td>
          <% else %>
            <%
              desired_id = -1
              requestors.each do |requestor|
                if requestor[:name] == session[:user].name
                  desired_id = requestor[:request_id]
                end
              end
            %>
            <td align="center"><%= link_to "Edit invitation", :controller => 'join_team_requests', :action => 'edit',
                  :id=>desired_id
                %>
              <img src="/assets/info.png" title="Edit your request to join this team">
            </td>
          <% end %>
        <% end %>
      </tr>
    <% end %>
  <% } %>

</table>





<commit_msg>Partial fix - stop people already on the team from editing request<commit_after><h2>
  Partner Advertisements for Topic: <%= SignUpTopic.find(params[:id]).topic_name %>
</h2>

<table class="general">
  <tr>
    <th width="500">Team Name</th>
    <th width="500">Members</th>
    <th width="500">Desired Qualifications</th>
    <th width="500">Action</th>
  </tr>

  <% requestors = [] %>
  <% requestors_names = [] %>

  <%# @results is the ad_info for an assignment's topic %>
  <% @results.each {|result| %>

    <%# Create a list of hashed requestors which have asked to join the team %>
    <% 
      @join_team_requests = JoinTeamRequest.where(team_id: result[:team_id])
      @join_team_requests.each do |join_team_request|
        if join_team_request.status=='P'
          requestors_names << User.find(Participant.find(join_team_request.participant_id).user_id).name
          requestors << {name: User.find(Participant.find(join_team_request.participant_id).user_id).name, request_id: join_team_request.id}
        end
      end 
    %>

    <%
      team_members = []
      TeamsUser.where(team_id: result[:team_id]).each{|teamuser|
        team_members << User.find(teamuser.user_id).name
      }
      if result[:advertise_for_partner]|| result[:advertise_for_partner] == 1
    %>
      <tr>
        <td align="center" width="500"><%= result[:name] %></td>
        <td align="center" width="500"><%= team_members.join(', ') %></td>
        <td align="center" width="500"><%= result[:comments_for_advertisement] %></td>
        <% if  Participant.where(parent_id: result[:assignment_id], user_id: session[:user].id).first && !team_members.include?(session[:user].name) && !requestors_names.include?(session[:user].name) %>
          <td align="center"><%= link_to "Request invitation", :controller => 'join_team_requests', :action => 'new',
            :assignment_id=>result[:assignment_id],
            :topic_id=>result[:topic_id],
            :team_id=>result[:team_id]
          %>
          <img src="/assets/info.png" title="Send request to join this team">
          </td>
<<<<<<< HEAD
        <% else %>
          <% if team_members.include?(session[:user].name) %>
            <td align="center"><img src="/assets/info.png" title="You're a member of this team and cannot request to join!"></td>
          <% else %>
            <%
              desired_id = -1
              requestors.each do |requestor|
                if requestor[:name] == session[:user].name
                  desired_id = requestor[:request_id]
                end
              end
            %>
            <td align="center"><%= link_to "Edit invitation", :controller => 'join_team_requests', :action => 'edit',
                  :id=>desired_id
                %>
              <img src="/assets/info.png" title="Edit your request to join this team">
            </td>
          <% end %>
        <% end %>
      </tr>
=======
      </tr>
    <% else %>
      <% if !team_members.include?(session[:user].name) %>
        <td align="center"><%= link_to "Edit invitation", :controller => 'join_team_requests', :action => 'edit',
              :id=>result[:request].id
            %>
          <img src="/assets/info.png" title="Edit your request to join this team">
        </td>
      <% else %>
        <td align="center"><%= "You are part of this team and cannot request to join" %></td>
      <% end %>
>>>>>>> 6c40347a1 (Partial fix - stop people already on the team from editing request)
    <% end %>
  <% end %>
  <% } %>

</table>






{'fraction_non_alphanumeric': 0.16529439179742117, 'fraction_numerical': 0.008855056703433277, 'mean_word_length': 2.5687361419068737, 'pattern_counts': {'":': 0, '<': 141, '<?xml version=': 0, '>': 148, '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': '515738', 'n_tokens_mistral': 2115, 'n_tokens_neox': 1953, 'n_words': 409}