diff --git a/Gemfile b/Gemfile index 435c2bbddc01858ed71ed58a1ab84908dc374d34..a2cf1522f959749985863f833084e1bfd9a52a59 100644 --- a/Gemfile +++ b/Gemfile @@ -86,3 +86,6 @@ gem 'jquery-rails' # Breadcrumbs gem 'breadcrumbs_on_rails' + +# Fake data for seeds +gem 'faker' diff --git a/Gemfile.lock b/Gemfile.lock index a18479eec204c1d643baf708a07cd045b10fbb35..75684aff041417f9488867892bb21a89829a7023 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,6 +103,8 @@ GEM concurrent-ruby (1.0.5) erubi (1.6.0) execjs (2.7.0) + faker (1.7.3) + i18n (~> 0.5) ffi (1.9.18) globalid (0.4.0) activesupport (>= 4.2.0) @@ -258,6 +260,7 @@ DEPENDENCIES capybara (~> 2.13.0) coffee-rails (~> 4.2) devise! + faker inline_svg jbuilder (~> 2.5) jquery-rails diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..1cf97fcc3e41c8286e4544fd1663b2b81c450bbe --- /dev/null +++ b/app/controllers/admin/projects_controller.rb @@ -0,0 +1,13 @@ +class Admin::ProjectsController < Admin::ApplicationController + + load_and_authorize_resource + + add_breadcrumb 'Projects', :admin_projects_path + + def index + end + + def show + add_breadcrumb "Project #{@project.id}", admin_project_path(@project) + end +end diff --git a/app/helpers/admin/projects_helper.rb b/app/helpers/admin/projects_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..348fb1f1a7ba5dc2b62b2750133b1a058998c381 --- /dev/null +++ b/app/helpers/admin/projects_helper.rb @@ -0,0 +1,2 @@ +module Admin::ProjectsHelper +end diff --git a/app/models/course_edition.rb b/app/models/course_edition.rb index 40d2b4ea8857ccd9bb12ca851fe1d94ef9603944..d7589a3340b89f56883046c328e7424ee897c4c2 100644 --- a/app/models/course_edition.rb +++ b/app/models/course_edition.rb @@ -6,7 +6,7 @@ class CourseEdition < ApplicationRecord belongs_to :course - enum status: [:closed, :open, :finished] + enum status: [:closed, :running, :finished] def effective_configuration configuration.present? ? configuration : course.configuration diff --git a/app/views/admin/projects/index.html.erb b/app/views/admin/projects/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..b44bbab2078b62f08d99057191c0f1a469630b01 --- /dev/null +++ b/app/views/admin/projects/index.html.erb @@ -0,0 +1,36 @@ +<div class="panel panel-default"> + + <table class="table table-striped"> + <thead> + <tr> + <th>ID</th> + <th><%= Project.human_attribute_name :name %></th> + <th><%= Project.human_attribute_name :status %></th> + <th><%= Project.human_attribute_name :company %></th> + <th><%= Project.human_attribute_name :created_at %></th> + </tr> + </thead> + <tbody> + <% @projects.each do |project| %> + <tr> + <td> + <%= project.id %> + </td> + <td> + <%= link_to project.name, admin_project_path(project.id) %> + </td> + <td> + <%= project.status %> + </td> + <td> + <%= project.company.name %> + </td> + <td> + <%= project.created_at %> + </td> + </tr> + <% end %> + </tbody> + </table> + +</div> diff --git a/app/views/admin/projects/show.html.erb b/app/views/admin/projects/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..27e01ba1b85818daa8897f3f4141f8207623b7c1 --- /dev/null +++ b/app/views/admin/projects/show.html.erb @@ -0,0 +1,4 @@ +<h2>Project <%= @project.id %></h2> +<div class= "project info"> + <p> <%= @project.description %> <p> +</div> diff --git a/app/views/layouts/admin/_navigation.html.erb b/app/views/layouts/admin/_navigation.html.erb index aa3a4bf345a4b6cb5ab70c3adc3833e51c808d7a..b68228a21833d90a8f686d9f6aefc71f0912f438 100644 --- a/app/views/layouts/admin/_navigation.html.erb +++ b/app/views/layouts/admin/_navigation.html.erb @@ -13,7 +13,8 @@ <ul class="nav navbar-nav"> <% { user: admin_users_path, - course: admin_courses_path + course: admin_courses_path, + project: admin_projects_path }.each do |name, url| %> <%= content_tag :li, class: (controller_name == name.to_s.pluralize ? 'active' : '') do %> <%= link_to t("#{name}.other", scope: 'activerecord.models'), url %> diff --git a/config/locales/en.yml b/config/locales/en.yml index eadd83b59bcdd2b61dd16ddd7a28440e990078a6..d9880129880adeae8c076fe08f757add0d1ff9d3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -86,3 +86,10 @@ en: affiliations: internal: Internal external: External + project: + name: Name + desciption: Description + status: Status + created_at: Created at + created_at: Created at + company: Company diff --git a/config/routes.rb b/config/routes.rb index 0d1dc848d8035b6b481fc20e375bfa132c2821eb..7d4c4f96d8fc7fd4e98aef57f0de42f5ef50e331 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,5 +8,6 @@ Rails.application.routes.draw do resources :users resources :courses resources :course_editions + resources :projects end end diff --git a/db/seeds.rb b/db/seeds.rb index e7f70c3ea5c046fe7e1bb56ba9a626fa8840d94f..f9a2d5fe77fa10fde8092759137d6bcdc65e4538 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -62,12 +62,14 @@ user.save! end -bp = Course.create name: 'Bachelor Project' -bp.editions << CourseEdition.new({ +edition = CourseEdition.new({ name: 'Bachelor Project Q4 2016-2017', starts_at: '2017-04-24', ends_at: '2017-07-09' }) + +bp = Course.create name: 'Bachelor Project' +bp.editions << edition bp.update configuration: CourseConfiguration.new({ min_group_size: 3, max_group_size: 4, @@ -84,10 +86,32 @@ external_company = Company.create({ description: 'Een arbitrair extern bedrijf dat projecten wil aanbieden.' }) -project = Project.create({ - name: 'Een Arbitrair Project', - company: external_company - }) +projects = Project.create([ + { + name: 'Een Arbitrair Project', + company: external_company, + course_edition: edition, + description: Faker::Lorem.paragraph(15) + }, + { + name: 'Software Development in Geldrop', + company: external_company, + course_edition: edition, + description: Faker::Lorem.paragraph(15) + }, + { + name: 'Testing in Texel', + company: external_company, + course_edition: edition, + description: Faker::Lorem.paragraph(15) + }, + { + name: 'User validation op Dumpert', + company: external_company, + course_edition: edition, + description: Faker::Lorem.paragraph(15) + } + ]) -external_user.add_role :client, project +external_user.add_role :client, projects[0] external_user.add_role :registrar, external_company diff --git a/test/controllers/admin/projects_controller_test.rb b/test/controllers/admin/projects_controller_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..9b9c31cfb9768f87737c9d671800cb4dc6838422 --- /dev/null +++ b/test/controllers/admin/projects_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class Admin::ProjectsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end