forked from hotsh/rstat.us
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class AdminController < ApplicationController | ||
def index | ||
logger.debug "current_user:" | ||
logger.debug current_user | ||
return if admin_only! | ||
|
||
@admin = admin_info | ||
end | ||
|
||
def update | ||
logger.debug session | ||
logger.debug "current_user:" | ||
logger.debug current_user | ||
return if admin_only! | ||
|
||
admin_info.multiuser = (params["multiuser"] == "on") | ||
admin_info.save | ||
|
||
redirect_to root_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# The Admin model contains system settings. | ||
|
||
class Admin | ||
include MongoMapper::Document | ||
|
||
# Whether or not user accounts can be created | ||
key :multiuser, Boolean | ||
|
||
def can_create_user? | ||
return !(User.count > 0 && !self.multiuser) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- title("Admin") | ||
- content_for :title do | ||
= "Admin" | ||
|
||
%h1 | ||
Administration | ||
|
||
%h2 | ||
User Accounts | ||
|
||
= form_for @admin, :url => "/admin", :html => {:name => "admin_form", :id => "admin-form", :class => "admin-form"} do |f| | ||
%label{:for => :multiuser} | ||
Allow New Accounts | ||
%input{:type => :checkbox, :name => :multiuser, :id => :multiuser, :checked => @admin.multiuser} | ||
|
||
%br | ||
|
||
%input{:type => :submit, :value => :save} |