Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
[#45] added cap deploy:seed, add position-to-role migrations, misc ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
Patrick Stoica committed Apr 19, 2014
1 parent dc95eea commit a2baa47
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def user_params
permitted = [
:username, :email, :subscribed_to_announce, :subscribed_to_staff,
:first_name, :middle_name, :last_name, :display_name,
:birthday_string, :avatar, :delete_avatar,
:status, :birthday_string, :avatar, :delete_avatar,
:phone, :admin, :exec_staff, role_ids: [],
legacy_profile_attributes: [
:id, :door1_access, :door2_access, :door3_access,
Expand Down
3 changes: 3 additions & 0 deletions app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class Role < ActiveRecord::Base
# these are generated with `rake db:seed`
# run 'cap deploy:seed' in production
DEFAULT_ROLES = [
{ name: "general_manager",
full_name: "General Manager"},
Expand All @@ -34,6 +35,8 @@ class Role < ActiveRecord::Base
full_name: "Music Director"},
{ name: "public_affairs_director",
full_name: "Public Affairs Director"},
{ name: "publicity_director",
full_name: "Publicity Director"},
{ name: "business_manager",
full_name: "Business Manager"},
{ name: "live_sound_director",
Expand Down
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class User < ActiveRecord::Base
# paperclip attachment for user avatars
attr_accessor :delete_avatar
before_validation { avatar.clear if delete_avatar == '1' }
has_attached_file :avatar, styles: { medium: "300x300>", thumb: "100x100>" },
has_attached_file :avatar,
styles: { medium: "300x300>", small: "100x100>", thumb: "32x32>" },
default_url: "/images/:style/missing.png"
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/

Expand Down
1 change: 1 addition & 0 deletions app/views/admin/users/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
= f.input_field :subscribed_to_announce, as: :boolean, inline_label: 'Annc List'
.col-sm-2
= f.input_field :subscribed_to_staff, as: :boolean, inline_label: 'Staff List'
= f.input :status, collection: User::STATUSES, include_blank: false, input_html: { class: 'form-control' }
= f.input :first_name, input_html: { class: 'form-control' }
= f.input :middle_name, input_html: { class: 'form-control' }
= f.input :last_name, input_html: { class: 'form-control' }
Expand Down
3 changes: 2 additions & 1 deletion app/views/admin/users/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ div ng-controller="adminUserCtrl"
span ng-switch-default=true
span.label.label-default No
td
span.label.label-default ng-repeat="role in user.roles" = "{{ role.full_name }}"
div ng-repeat="role in user.roles"
span.label.label-primary = "{{ role.full_name }}"
tr.ng-cloak ng-if="!loadingTracker.active() && filtered.length == 0"
td colspan="7" No results found.
tr ng-if="loadingTracker.active()"
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/_navigation.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
li.dropdown
a.dropdown-toggle data-toggle="dropdown" href="#"
i.glyphicon.glyphicon-user>
= current_user.name
strong> = current_user.username
span.text-muted = "- #{current_user.name}"
b.caret
ul.dropdown-menu
- if Settings.profiles_enabled?
Expand Down
5 changes: 5 additions & 0 deletions config/deploy.example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
end
end

desc "reload the database with seed data"
task :seed do
run "cd #{current_path}; bundle exec rake db:seed RAILS_ENV=#{rails_env}"
end

task :cold do
transaction do
update
Expand Down
75 changes: 75 additions & 0 deletions lib/tasks/sync_from_staff.rake
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,80 @@ task :sync_from_staff => :environment do |t, args|
user.save!

# add appropriate roles here
# if staff.md_privileges == 1
# user.add_role :music_director
# end

# if staff.auto_privileges == 1
# user.add_role :automation_czar
# user.add_role :psa_director
# end

unless staff.position.blank?
if staff.position.include? 'Sports Director'
user.add_role :sports_director
end

if staff.position.include? 'Automation Czar' or staff.position.include? 'PSA Director'
user.add_role :automation_czar
user.add_role :psa_director
end

if staff.position.include? 'Faculty Advisor'
user.add_role :faculty_advisor
end

if staff.position == 'Chief Engineer'
user.add_role :chief_engineer
end

if staff.position.include? 'Assistant Chief Engineer'
user.add_role :assistant_chief_engineer
end

if staff.position.include? 'Public Affairs Director'
user.add_role :public_affairs_director
end

if staff.position.include? 'Business Manager'
user.add_role :business_manager
end

if staff.position.include? 'Live Sound'
user.add_role :live_sound_director
end

if staff.position.include? 'IT Director'
user.add_role :it_director
end

if staff.position.include? 'Program Director'
user.add_role :program_director
end

if staff.position.include? 'Publicity Director'
user.add_role :publicity_director
end

if staff.position.include? 'Historian'
user.add_role :historian
end

if staff.position.include? 'General Manager'
user.add_role :general_manager
end

if staff.position.include? 'Operations Manager'
user.add_role :operations_manager
end

if staff.position.include? 'Contest Director'
user.add_role :contest_director
end

if staff.position.include? 'Student Media'
user.add_role :media_director
end
end
end
end

0 comments on commit a2baa47

Please sign in to comment.