diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index 019ddc38..030c65aa 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -35,16 +35,10 @@ class ContextController < ApplicationController # Creates a new context via Ajax helpers # def new_context - context = @user.contexts.build - context.attributes = params['context'] - context.name = deurlize(context.name) - - if context.save - render :partial => 'context_listing', :locals => { :context_listing => context } - else - flash["warning"] = "Couldn't add new context" - render :text => "#{flash["warning"]}" - end + @context = @user.contexts.build + @context.attributes = params['context'] + @context.name = deurlize(@context.name) + @saved = @context.save end # Called by a form button diff --git a/tracks/app/helpers/context_helper.rb b/tracks/app/helpers/context_helper.rb index bdd0d8ea..71e1485d 100644 --- a/tracks/app/helpers/context_helper.rb +++ b/tracks/app/helpers/context_helper.rb @@ -1,2 +1,12 @@ module ContextHelper + + def get_listing_sortable_options + { + :tag => 'div', + :handle => 'handle', + :complete => visual_effect(:highlight, 'list-contexts'), + :url => {:controller => 'context', :action => 'order'} + } + end + end diff --git a/tracks/app/models/context.rb b/tracks/app/models/context.rb index 8944364a..329abc4a 100644 --- a/tracks/app/models/context.rb +++ b/tracks/app/models/context.rb @@ -7,10 +7,11 @@ class Context < ActiveRecord::Base attr_protected :user # Context name must not be empty - # and must be less than 255 bytes + # and must be less than 256 characters validates_presence_of :name, :message => "context must have a name" - validates_length_of :name, :maximum => 255, :message => "context name must be less than %d" + validates_length_of :name, :maximum => 255, :message => "context name must be less than 256 characters" validates_uniqueness_of :name, :message => "already exists", :scope => "user_id" + validates_format_of :name, :with => /^[^\/]*$/i, :message => "cannot contain the slash ('/') character" def self.list_of(hidden=false) find(:all, :conditions => [ "hide = ?" , hidden ], :order => "position ASC") diff --git a/tracks/app/views/context/list.rhtml b/tracks/app/views/context/list.rhtml index 66c29c07..39faec8c 100644 --- a/tracks/app/views/context/list.rhtml +++ b/tracks/app/views/context/list.rhtml @@ -1,48 +1,32 @@ -
There were problems with the following fields: