Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

E318:Final Commit

  • Loading branch information...
commit 1e6cd34bff1a999d5cf92d507c4ab966d9f01f70 1 parent 50dcd99
Girish A Pandit authored
13 app/controllers/advertise_for_partner_controller.rb
... ... @@ -1,37 +1,38 @@
1 1 class AdvertiseForPartnerController < ApplicationController
  2 + #adds a new advertise for partners entry in team table...
2 3 def new
3 4 puts "team #{params[:team_id]}"
4 5 Team.update_all("advertise_for_partner=true",:id=>params[:team_id])
5 6 end
6   -
  7 + #removes an entry from team table for corresponding team who requested to remove their advertisement for partner request
7 8 def remove
8 9 Team.update_all("advertise_for_partner=false",:id=>params[:team_id])
9 10 assignment=Assignment.find(Team.find(params[:team_id]).parent_id)
10 11 participant=Participant.find_by_parent_id_and_user_id(assignment.id,session[:user].id)
11 12 redirect_to :controller => 'student_team', :action => 'view' , :id => participant.id
12 13 end
13   -
  14 + #update the team table with newly created advertise for partner request for the corresponding team
14 15 def add_advertise_comment
15 16 Team.update(params[:id],:comments_for_advertisement => params[:comment].to_s)
16 17 assignment=Assignment.find(Team.find(params[:id]).parent_id)
17 18 participant=Participant.find_by_parent_id_and_user_id(assignment.id,session[:user].id)
18 19 redirect_to :controller => 'student_team', :action => 'view' , :id => participant.id
19 20 end
20   -
  21 + #update the advertisement when done with editing #####This should be edit rather than update....
21 22 def update
22 23 @team=Team.find(params[:id])
23 24 @team.comments_for_advertisement = params[:team][:comments_for_advertisement]
24 25 assignment=Assignment.find(Team.find(params[:id]).parent_id)
25 26 participant=Participant.find_by_parent_id_and_user_id(assignment.id,session[:user].id)
26 27 if @team.save
27   - flash[:notice]='Advertisement edited successfully!'
  28 + flash[:notice]='Advertisement updated successfully!'
28 29 redirect_to :controller => 'student_team', :action => 'view' , :id => participant.id
29 30 else
30   - flash[:error]='Advertisement not edited successfully!'
  31 + flash[:error]='Advertisement not updated!'
31 32 redirect_to :controller => 'student_team', :action => 'view' , :id => participant.id
32 33 end
33 34 end
34   -
  35 + #find the team who wants to edit their advertisement
35 36 def edit
36 37 @team = Team.find(params[:team_id])
37 38 end
5 app/controllers/join_team_requests_controller.rb
@@ -37,6 +37,7 @@ def edit
37 37
38 38 # POST /join_team_requests
39 39 # POST /join_team_requests.xml
  40 + #create a new join team request entry for join_team_request table and add it to the table
40 41 def create
41 42 @join_team_request = JoinTeamRequest.new
42 43 @join_team_request.comments = params[:comments][0]
@@ -57,9 +58,9 @@ def create
57 58
58 59 # PUT /join_team_requests/1
59 60 # PUT /join_team_requests/1.xml
  61 + #update join team request entry for join_team_request table and add it to the table
60 62 def update
61 63 @join_team_request = JoinTeamRequest.find(params[:id])
62   -
63 64 respond_to do |format|
64 65 if @join_team_request.update_attributes(params[:join_team_request])
65 66 format.html { redirect_to(@join_team_request, :notice => 'JoinTeamRequest was successfully updated.') }
@@ -73,6 +74,7 @@ def update
73 74
74 75 # DELETE /join_team_requests/1
75 76 # DELETE /join_team_requests/1.xml
  77 +
76 78 def destroy
77 79 @join_team_request = JoinTeamRequest.find(params[:id])
78 80 @join_team_request.destroy
@@ -82,6 +84,7 @@ def destroy
82 84 format.xml { head :ok }
83 85 end
84 86 end
  87 + #decline request to join the team...
85 88 def decline
86 89 @join_team_request = JoinTeamRequest.find(params[:id])
87 90 @join_team_request.status = 'D'
8 app/controllers/sign_up_sheet_controller.rb
@@ -622,7 +622,7 @@ def set_start_due_date(assignment_id, set_of_topics)
622 622 }
623 623
624 624 end
625   -
  625 + #gets team_details to show it on team_details view for a given assignment
626 626 def team_details
627 627 if !(assignment = Assignment.find(params[:assignment_id])).nil? and !(topic = SignUpTopic.find(params[:id])).nil?
628 628 @results =get_team_details(assignment.id, topic.id)
@@ -648,15 +648,15 @@ def team_details
648 648 #@team_members = find_team_members(topic)
649 649 end
650 650 end
651   -
  651 + #searches and returns team members for a given team_id
652 652 def find_team_members(team_id)
653 653 TeamsUser.find_all_by_team_id(team_id).each{|teamuser|
654 654 team_members+=User.find(teamuser.user_id).handle+" "
655 655 }
656 656 end
657   -
658   -
659 657
  658 + #get the team details to display them in team_details view when assignment-participant
  659 + #clicks for seeing the advertisement related to
660 660 def get_team_details(assignment_id, topic_id)
661 661 query = "select t.name, t.comments_for_advertisement, p.handle,t.id as team_id, p.id as participant_id, p.topic_id as topic_id, p.parent_id as assignment_id"
662 662 query = query + " from teams t, teams_users tu, participants p"
1  app/views/join_team_requests/_list_received.html.erb
@@ -50,6 +50,7 @@
50 50 </td>
51 51 </tr>
52 52 <% end %>
  53 +
53 54 <% end %>
54 55 <% else %>
55 56 You Dont have any requests
6 app/views/join_team_requests/_list_sent.html.erb
@@ -42,8 +42,12 @@
42 42 <%= request.created_at %>
43 43 </td>
44 44 </tr>
45   -
46 45 <% end %>
  46 + <% else %>
  47 + <tr>
  48 + <td colspan ='4' > You didn't send any request yet</td>
  49 + </tr>
  50 +
47 51 <% end %>
48 52 </table>
49 53
16 app/views/join_team_requests/edit.html.erb
@@ -3,22 +3,14 @@
3 3 <% form_for(@join_team_request) do |f| %>
4 4 <%= f.error_messages %>
5 5
6   - <p>
7   - <%= f.label :participant_id %><br />
8   - <%= f.text_field :participant_id %>
9   - </p>
10   - <p>
11   - <%= f.label :team_id %><br />
12   - <%= f.text_field :team_id %>
13   - </p>
  6 + <%= f.hidden_field :participant_id %>
  7 + <%= f.hidden_field :team_id %>
  8 + <%= f.hidden_field :status %>
14 9 <p>
15 10 <%= f.label :comments %><br />
16 11 <%= f.text_area :comments %>
17 12 </p>
18   - <p>
19   - <%= f.label :status %><br />
20   - <%= f.text_field :status %>
21   - </p>
  13 +
22 14 <p>
23 15 <%= f.submit 'Update' %>
24 16 </p>
9 test/functional/advertise_for_partners_controller_test.rb
@@ -26,6 +26,15 @@ def test_edit
26 26 @team_advertisement_for_partner.save
27 27 assert_response :success
28 28 end
  29 + def test_remove
  30 + @team_advertisement_for_partner = Team.new(
  31 + :id => 32, :name => "test team", :parent_id => 2, :type => "AssignmentTeam", :comments_for_advertisement => "Hi test!!!", :advertise_for_partner=>true
  32 + )
  33 + @team_advertisement_for_partner.save
  34 + assert_not_nil(@team_advertisement_for_partner)
  35 + @team_advertisement_for_partner.advertise_for_partner=false
  36 + assert_equal(@team_advertisement_for_partner.advertise_for_partner?,false,'Advertisement removed')
  37 + end
29 38
30 39
31 40 end
35 test/functional/join_team_requests_controller_test.rb
... ... @@ -1,31 +1,32 @@
  1 +#require File.dirname(__FILE__) + '/../test_helper'
1 2 require 'test_helper'
  3 +#require 'join_team_requests_controller'
2 4
3   -class JoinTeamRequestTest < ActiveSupport::TestCase
  5 +class JoinTeamRequestsControllerTest < ActionController::TestCase
4 6 fixtures :join_team_requests
5   - # Replace this with your real tests.
6 7
7 8 def setup
8   - # Do nothing @course = courses(:course1)
9 9 @join_team_requests = join_team_requests(:one)
  10 + puts 'join_team:'+@join_team_requests.to_json
10 11 end
11   - def test_retrieval
12   - assert_kind_of JoinTeamRequest, @join_team_requests
13   - assert_equal join_team_requests(:one).participant_id, @join_team_requests.participant_id
14   - assert_equal join_team_requests(:one).team_id, @join_team_requests.team_id
15   - assert_equal 'MyText', @join_team_requests.comments
16   - assert_equal join_team_requests(:one).status, @join_team_requests.status
  12 +
  13 + def test_should_get_new
  14 + join_team_requests = JoinTeamRequest.new(:id => 1, :participant_id => 1, :team_id => 5, :comments => 'new Comments', :status => 'P')
  15 + assert join_team_requests.save
17 16 end
18 17
19   - def test_update
20   - assert_equal "MyText", @join_team_requests.comments
21   - @join_team_requests.comments = "Computer science"
22   - @join_team_requests.save
23   - @join_team_requests.reload
24   - assert_equal "Computer science", @join_team_requests.comments
  18 + test "should get edit" do
  19 + join_team_requests = JoinTeamRequest.find_by_participant_id(join_team_requests(:one).participant_id)
  20 + join_team_requests.comments = 'Hello'
  21 + join_team_requests.save
  22 + assert_response :success
25 23 end
26 24
27   - test "the truth" do
28   - assert true
  25 + test "should destroy join_team_request" do
  26 + assert_difference('JoinTeamRequest.count', -1) do
  27 + delete :destroy, :id => 11
  28 + end
  29 + assert_redirected_to join_team_requests_path
29 30 end
30 31 end
31 32

0 comments on commit 1e6cd34

Please sign in to comment.
Something went wrong with that request. Please try again.