Permalink
Browse files

Cleaned up dashboard auth, added some translations, and made registra…

…tion configurable closes #91
  • Loading branch information...
1 parent a6df9f4 commit c5f73c8fef1f2b0202c203f8110701bb7d1bd966 @augustf augustf committed May 24, 2012
View
2 app/controllers/dashboard_controller.rb
@@ -2,7 +2,7 @@ class DashboardController < ApplicationController
# GET /dashboard
def index
- authorize! :read, @concerto_config
+ authorize! :read, ConcertoConfig
@concerto_configs = ConcertoConfig.all
end
View
7 app/models/ability.rb
@@ -73,8 +73,11 @@ def user_abilities(user)
## Users
# A user can read and update themselves.
can [:read, :update], User, :id => user.id
- # An unauthenticated user can create a new user
- can :create, User unless user.persisted?
+ # An unauthenticated user can create a new user, if that's allowed globally
+ if ConcertoConfig[:allow_registration] == "true"
+ can :create, User unless user.persisted?
+ end
+
# The User#index action requires a special setup.
# By default, all the :read checks will pass because any
# user can read at least 1 user. We use this custom
View
2 app/views/elements/_topmenu_contents.html.erb
@@ -6,7 +6,7 @@
<nav id="TM">
<% if not user_signed_in? %>
<%= link_to "Concerto", "/", :id => "TM-logobutton" %>
- <p id="TM-logintext"><%= link_to t(:sign_in), new_user_session_path %> to upload and manage content. No account? <%= link_to t(:sign_up), new_user_registration_path %> now!</p>
+ <p id="TM-logintext"><%= link_to t(:sign_in), new_user_session_path %> <%=t(:signin_login_spiel) %> <% if ConcertoConfig[:allow_registration] == "true" %>No account? <%= link_to t(:sign_up), new_user_registration_path %> now!<% end %></p>
<% else %>
<%= link_to "Concerto", "/", :id => "TM-logobutton", :class => "full" %>
View
2 config/locales/en.yml
@@ -7,6 +7,8 @@ en:
membership_approved: "Approved"
membersip_denied: "Denied"
+ signin_login_spiel: "to upload and manage content."
+
#CanCan Exceptions localization (https://github.com/ryanb/cancan/wiki/exception-handling)
unauthorized:
read:
View
3 config/locales/views/dashboard/en.yml
@@ -7,4 +7,5 @@ en:
content_default_duration: "Default duration for content (in days)"
start_date_offset: "Time between submission and content start"
default_content_run_time: "Default content run time (in days)"
- setup_complete: "Concerto setup complete"
+ setup_complete: "Concerto setup complete"
+ allow_registration: "Allow open user registration"
View
1 db/seeds.rb
@@ -34,6 +34,7 @@
ConcertoConfig.find_or_create_by_key(:key => "start_date_offset", :value => "0", :value_default => "0", :value_type => "integer")
ConcertoConfig.find_or_create_by_key(:key => "default_content_run_time", :value => "7", :value_default => "7", :value_type => "integer")
ConcertoConfig.find_or_create_by_key(:key => "setup_complete", :value => "false", :value_default => "true", :value_type => "boolean")
+ConcertoConfig.find_or_create_by_key(:key => "allow_registration", :value => "true", :value_default => "true", :value_type => "boolean")
#Create an initial feed
Feed.find_or_create_by_name(:name => "Concerto", :description => "Initial Concerto Feed", :group_id => 1, :is_viewable => 1, :is_submittable => 1)

0 comments on commit c5f73c8

Please sign in to comment.