Commit 224fb5770ce71061861f5c2bddb01924d668a841
1 parent
010ac2b1
Exists in
master
and in
4 other branches
Added ability to manage groups from admin
Showing
11 changed files
with
26 additions
and
7 deletions
Show diff stats
app/controllers/admin/groups_controller.rb
| ... | ... | @@ -52,6 +52,14 @@ class Admin::GroupsController < AdminController |
| 52 | 52 | redirect_to :back, notice: 'Group was successfully updated.' |
| 53 | 53 | end |
| 54 | 54 | |
| 55 | + def remove_project | |
| 56 | + @project = Project.find(params[:project_id]) | |
| 57 | + @project.group_id = nil | |
| 58 | + @project.save | |
| 59 | + | |
| 60 | + redirect_to :back, notice: 'Group was successfully updated.' | |
| 61 | + end | |
| 62 | + | |
| 55 | 63 | def destroy |
| 56 | 64 | @group.destroy |
| 57 | 65 | ... | ... |
app/views/admin/groups/_form.html.haml
app/views/admin/groups/index.html.haml
app/views/admin/groups/show.html.haml
| 1 | += render 'admin/shared/projects_head' | |
| 1 | 2 | %h3.page_title |
| 2 | 3 | Group: #{@group.name} |
| 3 | 4 | = link_to edit_admin_group_path(@group), class: "btn right" do |
| ... | ... | @@ -38,6 +39,9 @@ |
| 38 | 39 | %li.wll |
| 39 | 40 | %strong |
| 40 | 41 | = link_to project.name, [:admin, project] |
| 42 | + .right | |
| 43 | + = link_to 'Remove from group', remove_project_admin_group_path(@group, project_id: project.id), confirm: 'Are you sure?', method: :delete, class: "btn danger small" | |
| 44 | + .clearfix | |
| 41 | 45 | |
| 42 | 46 | %br |
| 43 | 47 | %h3 Add new project | ... | ... |
app/views/admin/projects/index.html.haml
app/views/admin/projects/show.html.haml
app/views/groups/_projects.html.haml
| ... | ... | @@ -3,11 +3,6 @@ |
| 3 | 3 | Projects |
| 4 | 4 | %small |
| 5 | 5 | (#{projects.count}) |
| 6 | - - if current_user.can_create_project? | |
| 7 | - %span.right | |
| 8 | - = link_to new_project_path, class: "btn very_small info" do | |
| 9 | - %i.icon-plus | |
| 10 | - New Project | |
| 11 | 6 | %ul.unstyled |
| 12 | 7 | - projects.each do |project| |
| 13 | 8 | %li.wll | ... | ... |
app/views/layouts/admin.html.haml
| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | %ul.main_menu |
| 9 | 9 | = nav_link(controller: :dashboard, html_options: {class: 'home'}) do |
| 10 | 10 | = link_to "Stats", admin_root_path |
| 11 | - = nav_link(controller: :projects) do | |
| 11 | + = nav_link(controller: [:projects, :groups]) do | |
| 12 | 12 | = link_to "Projects", admin_projects_path |
| 13 | 13 | = nav_link(controller: :users) do |
| 14 | 14 | = link_to "Users", admin_users_path | ... | ... |
config/routes.rb