Skip to content

Commit

Permalink
Merge pull request #20031 from code-dot-org/project-permissions
Browse files Browse the repository at this point in the history
Project permissions for featuring
  • Loading branch information
Erin007 committed Jan 16, 2018
2 parents 52d755c + 181483a commit 1454ccb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions dashboard/app/models/user_permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class UserPermission < ActiveRecord::Base
# Grants access to reseting (to 0) the abuse score for projects,
# and blocking and unblocking legacy shares.
RESET_ABUSE = 'reset_abuse'.freeze,
# Grants ability to (un)feature projects in the the public project gallery.
PROJECT_VALIDATOR = 'project_validator'.freeze,
# Grants access to PLC workshop dashboards.
WORKSHOP_ADMIN = 'workshop_admin'.freeze,
# Grants access to managing professional development workshops and
Expand Down
23 changes: 12 additions & 11 deletions dashboard/app/views/levels/_admin.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- if current_user && (current_user.permission?(UserPermission::LEVELBUILDER) || current_user.permission?(UserPermission::RESET_ABUSE))
- if current_user && (current_user.permission?(UserPermission::LEVELBUILDER) || current_user.permission?(UserPermission::RESET_ABUSE) || current_user.permission?(UserPermission::PROJECT_VALIDATOR))
= render layout: 'shared/extra_links' do
%strong= @level.name
- if current_user.permission?(UserPermission::LEVELBUILDER)
Expand Down Expand Up @@ -73,16 +73,17 @@
= link_to build_script_level_path(script_level), build_script_level_path(script_level)
%br/
.project_admin
%br/
- if params[:channel_id]
- _, channel_id = storage_decrypt_channel_id(params[:channel_id])
- featured = FeaturedProject.exists?(:storage_app_id => channel_id)
#unfeature_project{'style' => ('display: none;' unless featured)}
%button{id: "feature", class: "btn btn-default btn-sm"}
Stop featuring in gallery
#feature_project{'style' => ('display: none;' if featured)}
%button{id: "feature", class: "btn btn-default btn-sm"}
Feature in gallery
- if current_user.permission?(UserPermission::PROJECT_VALIDATOR)
%br/
- if params[:channel_id]
- _, channel_id = storage_decrypt_channel_id(params[:channel_id])
- featured = FeaturedProject.exists?(:storage_app_id => channel_id)
#unfeature_project{'style' => ('display: none;' unless featured)}
%button{id: "feature", class: "btn btn-default btn-sm"}
Stop featuring in gallery
#feature_project{'style' => ('display: none;' if featured)}
%button{id: "feature", class: "btn btn-default btn-sm"}
Feature in gallery
- if current_user.permission?(UserPermission::RESET_ABUSE)
%br
Expand Down

0 comments on commit 1454ccb

Please sign in to comment.