Permalink
Browse files

respect the type, format comments

  • Loading branch information...
1 parent 6ab80ea commit b7959299e0999e86e5857939e4b2c8f9b0ca1120 Zach Rowe committed Jan 3, 2013
@@ -1,12 +1,6 @@
class TemplatesController < ApplicationController
before_filter :get_type, :only => [:new, :create, :import]
- # Grab the method of template
- # creation we're working with.
- def get_type
- @type = params[:type] || 'import'
- end
-
# GET /templates
# GET /templates.xml
def index
@@ -70,7 +64,7 @@ def create
format.html { redirect_to(@template, :notice => t(:template_created)) }
format.xml { render :xml => @template, :status => :created, :location => @template }
else
- format.html { render :action => "new" }
+ format.html { redirect_to new_template_path(@template, :type => 'create'), :locals => {:template => @template} }
format.xml { render :xml => @template.errors, :status => :unprocessable_entity }
end
end
@@ -208,4 +202,12 @@ def import
end
end
end
+
+private
+
+ # Grab the method of template
+ # creation we're working with.
+ def get_type
+ @type = params[:type] || 'import'
+ end
end
View
@@ -10,7 +10,7 @@ def initialize(accessor)
# Anything real can read a user
can :read, User if accessor.persisted?
- #Only define these permissive settings if concerto is set to be public
+ # Only define these permissive settings if concerto is set to be public
if ConcertoConfig[:public_concerto] == "true"
## Feeds
# Anything can read a viewable feed
@@ -112,8 +112,8 @@ def user_abilities(user)
screen.owner.user_has_permissions?(user, :regular, :screen, [:all]))
end
- #Subscriptions
- #Only the owning group or user can manage screen subscriptions
+ ## Subscriptions
+ # Only the owning group or user can manage screen subscriptions
can :manage, Subscription, :screen => { :owner_id => user.id, :owner_type => 'User'}
can :manage, Subscription do |subscription|
screen = subscription.screen
@@ -1,21 +1,21 @@
-#Current configuration keys:
- #public_concerto
- #default_upload_type
- #content_default_start_time
- #content_default_end_time
- #setup_complete
- #default_content_run_time
- #start_date_offset
+# Current configuration keys:
+ # public_concerto
+ # default_upload_type
+ # content_default_start_time
+ # content_default_end_time
+ # setup_complete
+ # default_content_run_time
+ # start_date_offset
-#Adding a new configuration variable:
- #Either in your plugin, or in the seeds file, add a row as such:
+# Adding a new configuration variable:
+ # Either in your plugin, or in the seeds file, add a row as such:
# ConcertoConfig.find_or_create_by_key(:key => "default_upload_type", :value => "graphic", :value_default => "graphic", :value_type => "string")
- #The value type and default will allow the Dashboard to properly create the form for editing the variable
- #Also ensure to provide a translation in an appropriate YAML file:
+ # The value type and default will allow the Dashboard to properly create the form for editing the variable
+ # Also ensure to provide a translation in an appropriate YAML file:
# default_upload_type: "Default content upload type"
- #The variable can then be accessed like this: ConcertoConfig[:public_concerto]
- #and modified by calling ConcertoConfig.set(public_concerto,true)
+ # The variable can then be accessed like this: ConcertoConfig[:public_concerto]
+ # and modified by calling ConcertoConfig.set(public_concerto,true)
class ConcertoConfig < ActiveRecord::Base
@@ -31,7 +31,7 @@ def self.[](key)
self.get(key.to_s)
end
- #Make setting values from Rails nice and easy
+ # Make setting values from Rails nice and easy
def self.set(key,value)
#only set this if the config already exists
setting = ConcertoConfig.where(:key => key).first # || ConcertoConfig.new(:key => key)
@@ -48,16 +48,16 @@ def self.get(key)
return setting.value
end
- #Creates a Concerto Config entry by taking the key and value desired
- #Also takes the following options: value_type, value_default, name, group, description, plugin_config, and plugin_id
- #If they're not specified, the type is assumed to be string and the default value the key that is set
+ # Creates a Concerto Config entry by taking the key and value desired
+ # Also takes the following options: value_type, value_default, name, group, description, plugin_config, and plugin_id
+ # If they're not specified, the type is assumed to be string and the default value the key that is set
def self.make_concerto_config(config_key,config_value, options={})
defaults = {
:value_type => "string",
:value_default => config_key
}
options = defaults.merge(options)
- #first_or_create check whether first returns nil or not; if it does return nil, create is called
+ # first_or_create: check whether first returns nil or not; if it does return nil, create is called
ConcertoConfig.where(:key => config_key).first_or_create(:key => config_key, :value => config_value,
:value_default => options[:value_default], :value_type => options[:value_type], :name => options[:name], :group => options[:group],
:description => options[:description], :plugin_config => options[:plugin_config], :plugin_id => options[:plugin_id], :hidden => options[:hidden])
View
@@ -8,7 +8,7 @@ class Content < ActiveRecord::Base
accepts_nested_attributes_for :media
accepts_nested_attributes_for :submissions
- #Validations
+ # Validations
validates :name, :presence => true
#validates :kind, :presence => true, :associated => true
validates :user, :presence => true, :associated => true
@@ -28,17 +28,17 @@ def parent_id_cannot_be_this_content
# or (more likely) gets removed.
default_scope { where(:type => Content.subclasses.collect { |s| s.name }) unless Rails.env.development? }
- #Easily query for active, expired, or future content
+ # Easily query for active, expired, or future content
scope :expired, where("end_time < :now", {:now => Clock.time})
scope :future, where("start_time > :now", {:now => Clock.time})
scope :active, where("(start_time IS NULL OR start_time < :now) AND (end_time IS NULL OR end_time > :now)", {:now => Clock.time})
- #Scoped relations for feed approval states
+ # Scoped relations for feed approval states
has_many :approved_feeds, :through => :submissions, :source => :feed, :conditions => {"submissions.moderation_flag" => true}
has_many :pending_feeds, :through => :submissions, :source => :feed, :conditions => "submissions.moderation_flag IS NULL"
has_many :denied_feeds, :through => :submissions, :source => :feed, :conditions => {"submissions.moderation_flag" => false}
- #Magic to let us generate routes
+ # Magic to let us generate routes
delegate :url_helpers, :to => 'Rails.application.routes'
# Determine if content is active based on its start and end times.
View
@@ -4,12 +4,12 @@ class Feed < ActiveRecord::Base
has_many :contents, :through => :submissions
has_many :subscriptions, :dependent => :destroy
- #Scoped relations for content approval states
+ # Scoped relations for content approval states
has_many :approved_contents, :through => :submissions, :source => :content, :conditions => {"submissions.moderation_flag" => true}
has_many :pending_contents, :through => :submissions, :source => :content, :conditions => "submissions.moderation_flag IS NULL"
has_many :denied_contents, :through => :submissions, :source => :content, :conditions => {"submissions.moderation_flag" => false}
- #Validations
+ # Validations
validates :name, :presence => true, :uniqueness => true
validates :group, :presence => true, :associated => true
validate :parent_id_cannot_be_this_feed
@@ -20,7 +20,7 @@ def parent_id_cannot_be_this_feed
end
end
- #Feed Hierachy
+ # Feed Hierarchy
belongs_to :parent, :class_name => "Feed"
has_many :children, :class_name => "Feed", :foreign_key => "parent_id"
scope :roots, where(:parent_id => nil)
View
@@ -3,6 +3,6 @@ class Field < ActiveRecord::Base
has_many :subscriptions, :dependent => :destroy
has_many :positions
- #Validations
+ # Validations
validates :name, :presence => true
end
View
@@ -9,7 +9,7 @@ class Group < ActiveRecord::Base
# Scoped relation for members and pending members
has_many :all_users, :through => :memberships, :source => :user, :conditions => ["memberships.level != ?", Membership::LEVELS[:denied]]
- # Scoped relations for leaders
+ # Scoped relation for leaders
has_many :leaders, :through => :memberships, :source => :user, :conditions => {"memberships.level" => Membership::LEVELS[:leader]}
# Validations
@@ -24,8 +24,8 @@ def update_membership_perms
end
end
- #Deliver a list of only users not currently in the group
- #Used for adding new users to a group and avoiding duplication
+ # Deliver a list of only users not currently in the group
+ # Used for adding new users to a group and avoiding duplication
def users_not_in_group
users = User.all
self.memberships.each do |m|
View
@@ -2,6 +2,6 @@ class Kind < ActiveRecord::Base
has_many :contents
has_many :fields
- #Validations
+ # Validations
validates :name, :presence => true, :uniqueness => true
end
View
@@ -3,7 +3,7 @@ class Media < ActiveRecord::Base
attachable
- #Validations
+ # Validations
validates :file_type, :presence => true
validates :file_size, :numericality => { :greater_than_or_equal_to => 0 }
View
@@ -49,6 +49,7 @@ class Membership < ActiveRecord::Base
scope :denied, where(:level => Membership::LEVELS[:denied])
attr_accessor :perms
+
def expand_permissions
self.perms = {}
level_sym = level_name.to_sym
@@ -132,7 +133,7 @@ def approve()
end
end
- #Make a regular member a group leader
+ # Make a regular member a group leader
def promote_to_leader
if update_attributes({:level => Membership::LEVELS[:leader]})
true
View
@@ -4,7 +4,7 @@ class Position < ActiveRecord::Base
before_save :clean_styles
- #Validations
+ # Validations
validates :field, :presence => true, :associated => true
validates :right, :numericality => {:greater_than_or_equal_to => -1, :less_than_or_equal_to => 1}
validates :left, :numericality => {:greater_than_or_equal_to => -1, :less_than_or_equal_to => 1}
View
@@ -5,7 +5,7 @@ class Screen < ActiveRecord::Base
has_many :positions, :through => :template
has_many :fields, :through => :positions
- #Validations
+ # Validations
validates :name, :presence => true
validates :template, :presence => true, :associated => true
#These two validations are used to solve problems with the polymorphic
@@ -23,7 +23,7 @@ class Screen < ActiveRecord::Base
scope :online, where(:is_public => true)
scope :offline, where(:is_public => false)
- #types of entities that may "own" a screen
+ # types of entities that may "own" a screen
SCREEN_OWNER_TYPES = ["User", "Group"]
# Determine the screen's aspect ratio. If it doesn't exist, calculate it
View
@@ -5,19 +5,19 @@ class Submission < ActiveRecord::Base
after_save :update_children_moderation_flag
- #Validations
+ # Validations
validates :feed, :presence => true, :associated => true
validates :content, :presence => true, :associated => true
validates :moderator, :presence => { :unless => :is_pending? }, :associated => true
validates :duration, :numericality => { :greater_than => 0 }
validates_uniqueness_of :content_id, :scope => :feed_id #Enforce content can only be submitted to a feed once
- #Scoping shortcuts for approved/denied/pending
+ # Scoping shortcuts for approved/denied/pending
scope :approved, where(:moderation_flag => true)
scope :denied, where(:moderation_flag => false)
scope :pending, where("moderation_flag IS NULL")
- #Scoping shortcuts for active/expired/future
+ # Scoping shortcuts for active/expired/future
scope :active, joins(:content).merge(Content.active)
scope :expired, joins(:content).merge(Content.expired)
scope :future, joins(:content).merge(Content.future)
@@ -13,16 +13,17 @@ class Subscription < ActiveRecord::Base
# A very infrequent chance of content showing up.
:"very rarely" => 1,
}
+
# Associations
belongs_to :feed
belongs_to :field
belongs_to :screen
- #Validations
+ # Validations
validates :feed, :presence => true, :associated => true
validates_uniqueness_of :feed_id, :scope => [:screen_id, :field_id]
- #Get weight name of a subscription
+ # Get weight name of a subscription
def weight_name
name = (Subscription::WEIGHTS.respond_to?(:key) ? Subscription::WEIGHTS.key(weight) : Subscription::WEIGHTS.index(weight)).to_s
end
View
@@ -5,7 +5,7 @@ class Template < ActiveRecord::Base
accepts_nested_attributes_for :media
- #Validations
+ # Validations
validates :name, :presence => true
#Placeholder attributes
View
@@ -4,7 +4,7 @@ class Ticker < Content
after_initialize :set_kind
- #Validations
+ # Validations
validates :duration, :numericality => { :greater_than => 0 }
validates :data, :presence => true
@@ -4,7 +4,7 @@ class TimeDisplay < Content
after_initialize :set_kind
- #Validations
+ # Validations
validates :duration, :numericality => { :greater_than => 0 }
# Automatically set the kind for the content
View
@@ -4,7 +4,7 @@ class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
- # Setup accessible (or protected) attributes for your model
+ # Setup accessible attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :locale, :is_admin
has_many :contents
@@ -16,7 +16,7 @@ class User < ActiveRecord::Base
has_many :groups, :through => :memberships, :conditions => ["memberships.level > ?", Membership::LEVELS[:pending]]
has_many :leading_groups, :through => :memberships, :source => :group, :conditions => {"memberships.level" => Membership::LEVELS[:leader]}
- #Validations
+ # Validations
validates :email, :presence => true, :uniqueness => true
validates :first_name, :presence => true
@@ -44,6 +44,6 @@
<div class="submit_bar actions">
- <%= f.submit t(:submit), :class => "btn primary" %>
+ <%= f.submit t(:submit, :model => 'template'), :class => "btn primary" %>
</div>
<% end %>

0 comments on commit b795929

Please sign in to comment.