voluntary_scholarship 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +23 -0
  4. data/app/controllers/concerns/scholarship/base_controller.rb +17 -0
  5. data/app/controllers/product/scholarship_controller.rb +6 -0
  6. data/app/controllers/scholarship/iteration_participations_controller.rb +80 -0
  7. data/app/controllers/scholarship/iterations_controller.rb +72 -0
  8. data/app/controllers/scholarship/programs_controller.rb +66 -0
  9. data/app/controllers/scholarship/team_memberships_controller.rb +77 -0
  10. data/app/controllers/scholarship/teams_controller.rb +63 -0
  11. data/app/controllers/scholarship/workflow/organization_owner_controller.rb +10 -0
  12. data/app/controllers/scholarship/workflow/team_leader_controller.rb +10 -0
  13. data/app/controllers/scholarship/workflow_controller.rb +10 -0
  14. data/app/helpers/voluntary_scholarship/iteration_participations_helper.rb +19 -0
  15. data/app/helpers/voluntary_scholarship/team_memberships_helper.rb +19 -0
  16. data/app/models/concerns/scholarship/role_request.rb +36 -0
  17. data/app/models/product/scholarship.rb +2 -0
  18. data/app/models/scholarship/iteration.rb +36 -0
  19. data/app/models/scholarship/iteration_participation.rb +66 -0
  20. data/app/models/scholarship/program.rb +18 -0
  21. data/app/models/scholarship/team.rb +33 -0
  22. data/app/models/scholarship/team_membership.rb +22 -0
  23. data/app/views/product/scholarship/index.html.erb +0 -0
  24. data/app/views/scholarship/iteration_participations/_actions.html.erb +18 -0
  25. data/app/views/scholarship/iteration_participations/_collection.html.erb +51 -0
  26. data/app/views/scholarship/iteration_participations/_form.html.erb +23 -0
  27. data/app/views/scholarship/iteration_participations/edit.html.erb +3 -0
  28. data/app/views/scholarship/iteration_participations/index.html.erb +3 -0
  29. data/app/views/scholarship/iteration_participations/new.html.erb +3 -0
  30. data/app/views/scholarship/iteration_participations/with_state.html.erb +1 -0
  31. data/app/views/scholarship/iterations/_actions.html.erb +19 -0
  32. data/app/views/scholarship/iterations/_form.html.erb +14 -0
  33. data/app/views/scholarship/iterations/edit.html.erb +3 -0
  34. data/app/views/scholarship/iterations/index.html.erb +33 -0
  35. data/app/views/scholarship/iterations/new.html.erb +3 -0
  36. data/app/views/scholarship/iterations/show.html.erb +9 -0
  37. data/app/views/scholarship/programs/_actions.html.erb +19 -0
  38. data/app/views/scholarship/programs/_form.html.erb +13 -0
  39. data/app/views/scholarship/programs/edit.html.erb +3 -0
  40. data/app/views/scholarship/programs/index.html.erb +33 -0
  41. data/app/views/scholarship/programs/new.html.erb +3 -0
  42. data/app/views/scholarship/programs/show.html.erb +11 -0
  43. data/app/views/scholarship/team_memberships/_actions.html.erb +18 -0
  44. data/app/views/scholarship/team_memberships/_collection.html.erb +47 -0
  45. data/app/views/scholarship/team_memberships/_form.html.erb +22 -0
  46. data/app/views/scholarship/team_memberships/edit.html.erb +3 -0
  47. data/app/views/scholarship/team_memberships/index.html.erb +3 -0
  48. data/app/views/scholarship/team_memberships/new.html.erb +3 -0
  49. data/app/views/scholarship/team_memberships/with_state.html.erb +1 -0
  50. data/app/views/scholarship/teams/_actions.html.erb +19 -0
  51. data/app/views/scholarship/teams/_form.html.erb +15 -0
  52. data/app/views/scholarship/teams/edit.html.erb +3 -0
  53. data/app/views/scholarship/teams/index.html.erb +29 -0
  54. data/app/views/scholarship/teams/new.html.erb +3 -0
  55. data/app/views/scholarship/teams/show.html.erb +19 -0
  56. data/app/views/scholarship/workflow/index.html.erb +0 -0
  57. data/app/views/scholarship/workflow/organization_owner/index.html.erb +24 -0
  58. data/app/views/scholarship/workflow/team_leader/index.html.erb +24 -0
  59. data/config/locales/products/scholarship/workflow/en.yml +12 -0
  60. data/config/locales/resources/scholarship_iteration/en.yml +22 -0
  61. data/config/locales/resources/scholarship_iteration_participation/en.yml +39 -0
  62. data/config/locales/resources/scholarship_program/en.yml +16 -0
  63. data/config/locales/resources/scholarship_team/en.yml +23 -0
  64. data/config/locales/resources/scholarship_team_membership/en.yml +30 -0
  65. data/config/main_scholarship_navigation.rb +3 -0
  66. data/config/routes.rb +54 -0
  67. data/db/migrate/20140306201232_add_scholarship_product.rb +12 -0
  68. data/db/migrate/20140310181004_create_scholarship_programs.rb +12 -0
  69. data/db/migrate/20140310192931_create_scholarship_iterations.rb +13 -0
  70. data/db/migrate/20140311173818_create_scholarship_teams.rb +28 -0
  71. data/db/migrate/20140314154216_create_scholarship_iteration_participations.rb +15 -0
  72. data/db/schema.rb +85 -0
  73. data/lib/tasks/voluntary_scholarship_tasks.rake +4 -0
  74. data/lib/voluntary_scholarship.rb +13 -0
  75. data/lib/voluntary_scholarship/ability.rb +34 -0
  76. data/lib/voluntary_scholarship/concerns/model/has_scholarship_programs.rb +13 -0
  77. data/lib/voluntary_scholarship/concerns/model/user/has_scholarship_teams.rb +43 -0
  78. data/lib/voluntary_scholarship/engine.rb +28 -0
  79. data/lib/voluntary_scholarship/navigation.rb +114 -0
  80. data/lib/voluntary_scholarship/version.rb +3 -0
  81. metadata +468 -0
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = VoluntaryScholarship
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,23 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'VoluntaryScholarship'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
@@ -0,0 +1,17 @@
1
+ module Scholarship
2
+ module BaseController
3
+ extend ActiveSupport::Concern
4
+
5
+ def application_navigation
6
+ :main_scholarship
7
+ end
8
+
9
+ def navigation_product_path
10
+ scholarship_product_path
11
+ end
12
+
13
+ def navigation_product_name
14
+ 'Scholarship'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ class Product::ScholarshipController < ApplicationController
2
+ include ::Scholarship::BaseController
3
+
4
+ def index
5
+ end
6
+ end
@@ -0,0 +1,80 @@
1
+ class Scholarship::IterationParticipationsController < ApplicationController
2
+ include ::Scholarship::BaseController
3
+ include Applicat::Mvc::Controller::Resource
4
+ include VoluntaryScholarship::IterationParticipationsHelper
5
+
6
+ transition_actions Scholarship::IterationParticipation::EVENTS
7
+
8
+ before_filter :find_iteration_participation, only: [:new]
9
+
10
+ load_and_authorize_resource
11
+
12
+ rescue_from ActiveRecord::RecordNotFound, with: :not_found
13
+
14
+ def index
15
+ @iteration = Scholarship::Iteration.find(params[:iteration_id])
16
+ @program = @iteration.program
17
+ @iteration_participations = @iteration.participations.accepted.order_by_user_full_name.paginate(page: params[:page], per_page: 25)
18
+ end
19
+
20
+ def new
21
+ end
22
+
23
+ def create
24
+ @iteration_participation = Scholarship::IterationParticipation.new(params[:scholarship_iteration_participation])
25
+ @iteration_participation.user = current_user
26
+ @iteration = @iteration_participation.iteration
27
+ @program = @iteration.program
28
+
29
+ if @iteration_participation.save
30
+ redirect_to scholarship_iteration_participants_path(@iteration_participation.iteration), notice: t('general.form.successfully_created')
31
+ else
32
+ render :new
33
+ end
34
+ end
35
+
36
+ def edit
37
+ end
38
+
39
+ def update
40
+ if params[:scholarship_iteration_participation][:roles].present? && !can_update_scholarship_iteration_participation_roles?(@iteration_participation)
41
+ raise CanCan::AccessDenied
42
+ end
43
+
44
+ if @iteration_participation.update_attributes(params[:scholarship_iteration_participation])
45
+ redirect_to [:edit, @iteration_participation], notice: t('general.form.successfully_updated')
46
+ else
47
+ render :edit
48
+ end
49
+ end
50
+
51
+ def destroy
52
+ @iteration_participation.destroy
53
+ redirect_to scholarship_iteration_participants_path(@iteration_participation.iteration), notice: t('general.form.destroyed')
54
+ end
55
+
56
+ def resource
57
+ @iteration_participation
58
+ end
59
+
60
+ def with_state
61
+ @iteration_participations = Scholarship::IterationParticipation.of_organization_owner(current_user).send(params[:state]).
62
+ order_by_user_full_name.includes(iteration: { program: :organization}).paginate(page: params[:page], per_page: 25)
63
+ render layout: false
64
+ end
65
+
66
+ private
67
+
68
+ def find_iteration_participation
69
+ @iteration_participation = case action_name
70
+ when 'new'
71
+ @iteration = Scholarship::Iteration.find(params[:iteration_id])
72
+ @program = @iteration.program
73
+ @iteration.participations.new
74
+ end
75
+ end
76
+
77
+ def not_found
78
+ redirect_to root_path, notice: t('general.exceptions.not_found')
79
+ end
80
+ end
@@ -0,0 +1,72 @@
1
+ class Scholarship::IterationsController < ApplicationController
2
+ include ::Scholarship::BaseController
3
+ include Applicat::Mvc::Controller::Resource
4
+
5
+ before_filter :find_iteration, only: [:new]
6
+
7
+ load_and_authorize_resource
8
+
9
+ rescue_from ActiveRecord::RecordNotFound, with: :not_found
10
+
11
+ def index
12
+ @program = Scholarship::Program.find(params[:program_id])
13
+ @iterations = @program.iterations.paginate(page: params[:page], per_page: 25).order('scholarship_iterations.from DESC')
14
+ end
15
+
16
+ def show
17
+ @program = @iteration.program
18
+ end
19
+
20
+ def new
21
+ end
22
+
23
+ def create
24
+ @iteration = Scholarship::Iteration.new(params[:scholarship_iteration])
25
+
26
+ if @iteration.save
27
+ redirect_to @iteration, notice: t('general.form.successfully_created')
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ def edit
34
+ end
35
+
36
+ def update
37
+ if @iteration.update_attributes(params[:scholarship_iteration])
38
+ redirect_to @iteration, notice: t('general.form.successfully_updated')
39
+ else
40
+ render :edit
41
+ end
42
+ end
43
+
44
+ def destroy
45
+ @iteration.destroy
46
+ redirect_to scholarship_program_iterations_path(@iteration.program), notice: t('general.form.destroyed')
47
+ end
48
+
49
+ def resource
50
+ @iteration
51
+ end
52
+
53
+ protected
54
+
55
+ def set_twitter_sidenav_level
56
+ @twitter_sidenav_level = 5
57
+ end
58
+
59
+ private
60
+
61
+ def find_iteration
62
+ @iteration = case action_name
63
+ when 'new'
64
+ @program = Scholarship::Program.find(params[:program_id])
65
+ @program.iterations.new
66
+ end
67
+ end
68
+
69
+ def not_found
70
+ redirect_to root_path, notice: t('general.exceptions.not_found')
71
+ end
72
+ end
@@ -0,0 +1,66 @@
1
+ class Scholarship::ProgramsController < ApplicationController
2
+ include ::Scholarship::BaseController
3
+ include Applicat::Mvc::Controller::Resource
4
+
5
+ before_filter :find_program, only: [:new]
6
+
7
+ load_and_authorize_resource
8
+
9
+ rescue_from ActiveRecord::RecordNotFound, with: :not_found
10
+
11
+ def index
12
+ @organization = find_parent Scholarship::Program::PARENT_TYPES
13
+ @programs = @organization ? @organization.scholarship_programs.order(:name) : Scholarship::Program.order(:name)
14
+ @programs = @programs.paginate(page: params[:page], per_page: 25)
15
+ end
16
+
17
+ def show
18
+ end
19
+
20
+ def new
21
+ end
22
+
23
+ def create
24
+ @program = Scholarship::Program.new(params[:scholarship_program])
25
+
26
+ if @program.save
27
+ redirect_to @program, notice: t('general.form.successfully_created')
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ def edit
34
+ end
35
+
36
+ def update
37
+ if @program.update_attributes(params[:scholarship_program])
38
+ redirect_to @program, notice: t('general.form.successfully_updated')
39
+ else
40
+ render :edit
41
+ end
42
+ end
43
+
44
+ def destroy
45
+ @program.destroy
46
+ redirect_to organization_scholarship_programs_path(@program.organization), notice: t('general.form.destroyed')
47
+ end
48
+
49
+ def resource
50
+ @program
51
+ end
52
+
53
+ private
54
+
55
+ def find_program
56
+ @program = case action_name
57
+ when 'new' then
58
+ @organization = Organization.friendly.find(params[:organization_id]) if params[:organization_id].present?
59
+ @organization.present? ? @organization.scholarship_programs.new : Scholarship::Program.new
60
+ end
61
+ end
62
+
63
+ def not_found
64
+ redirect_to scholarship_programs_path, notice: t('general.exceptions.not_found')
65
+ end
66
+ end
@@ -0,0 +1,77 @@
1
+ class Scholarship::TeamMembershipsController < ApplicationController
2
+ include ::Scholarship::BaseController
3
+ include Applicat::Mvc::Controller::Resource
4
+ include VoluntaryScholarship::TeamMembershipsHelper
5
+
6
+ transition_actions Scholarship::TeamMembership::EVENTS
7
+
8
+ before_filter :find_team_membership, only: [:new]
9
+
10
+ load_and_authorize_resource
11
+
12
+ rescue_from ActiveRecord::RecordNotFound, with: :not_found
13
+
14
+ def index
15
+ @team = Scholarship::Team.friendly.find(params[:team_id])
16
+ @team_memberships = @team.memberships.accepted.order_by_user_full_name.paginate(page: params[:page], per_page: 25)
17
+ end
18
+
19
+ def new
20
+ end
21
+
22
+ def create
23
+ @team_membership = Scholarship::TeamMembership.new(params[:scholarship_team_membership])
24
+ @team_membership.user = current_user
25
+ @team = @team_membership.team
26
+
27
+ if @team_membership.save
28
+ redirect_to scholarship_team_members_path(@team_membership.team), notice: t('general.form.successfully_created')
29
+ else
30
+ render :new
31
+ end
32
+ end
33
+
34
+ def edit
35
+ end
36
+
37
+ def update
38
+ if params[:scholarship_team_membership][:roles].present? && !can_update_scholarship_team_membership_roles?(@team_membership)
39
+ raise CanCan::AccessDenied
40
+ end
41
+
42
+ if @team_membership.update_attributes(params[:scholarship_team_membership])
43
+ redirect_to [:edit, @team_membership], notice: t('general.form.successfully_updated')
44
+ else
45
+ render :edit
46
+ end
47
+ end
48
+
49
+ def destroy
50
+ @team_membership.destroy
51
+ redirect_to scholarship_team_members_path(@team_membership.team), notice: t('general.form.destroyed')
52
+ end
53
+
54
+ def resource
55
+ @team_membership
56
+ end
57
+
58
+ def with_state
59
+ @team_memberships = Scholarship::TeamMembership.of_team_leader(current_user).send(params[:state]).
60
+ order_by_user_full_name.includes(:team).paginate(page: params[:page], per_page: 25)
61
+ render layout: false
62
+ end
63
+
64
+ private
65
+
66
+ def find_team_membership
67
+ @team_membership = case action_name
68
+ when 'new'
69
+ @team = Scholarship::Team.friendly.find(params[:team_id])
70
+ @team.memberships.new
71
+ end
72
+ end
73
+
74
+ def not_found
75
+ redirect_to root_path, notice: t('general.exceptions.not_found')
76
+ end
77
+ end
@@ -0,0 +1,63 @@
1
+ class Scholarship::TeamsController < ApplicationController
2
+ include ::Scholarship::BaseController
3
+ include Applicat::Mvc::Controller::Resource
4
+
5
+ before_filter :find_team, only: [:show, :edit, :update, :destroy]
6
+
7
+ load_and_authorize_resource
8
+
9
+ rescue_from ActiveRecord::RecordNotFound, with: :not_found
10
+
11
+ def index
12
+ @teams = Scholarship::Team.order(:name)
13
+ @teams = @teams.paginate(page: params[:page], per_page: 25)
14
+ end
15
+
16
+ def show
17
+ end
18
+
19
+ def new
20
+ @team = Scholarship::Team.new(kind: 'sponsored')
21
+ end
22
+
23
+ def create
24
+ @team = Scholarship::Team.new(params[:scholarship_team])
25
+ @team.leader = current_user
26
+
27
+ if @team.save
28
+ redirect_to @team, notice: t('general.form.successfully_created')
29
+ else
30
+ render :new
31
+ end
32
+ end
33
+
34
+ def edit
35
+ end
36
+
37
+ def update
38
+ if @team.update_attributes(params[:scholarship_team])
39
+ redirect_to @team, notice: t('general.form.successfully_updated')
40
+ else
41
+ render :edit
42
+ end
43
+ end
44
+
45
+ def destroy
46
+ @team.destroy
47
+ redirect_to scholarship_teams_path, notice: t('general.form.destroyed')
48
+ end
49
+
50
+ def resource
51
+ @team
52
+ end
53
+
54
+ private
55
+
56
+ def find_team
57
+ @team = Scholarship::Team.friendly.find(params[:id])
58
+ end
59
+
60
+ def not_found
61
+ redirect_to scholarship_teams_path, notice: t('general.exceptions.not_found')
62
+ end
63
+ end
@@ -0,0 +1,10 @@
1
+ class Scholarship::Workflow::OrganizationOwnerController < ApplicationController
2
+ include ::Scholarship::BaseController
3
+
4
+ before_filter :authenticate_user!
5
+
6
+ def index
7
+ @iteration_participations = Scholarship::IterationParticipation.of_organization_owner(current_user).requested.
8
+ order_by_user_full_name.includes(iteration: { program: :organization}).paginate(page: params[:page], per_page: 25)
9
+ end
10
+ end