diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index 274360f..c80593f 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -26,9 +26,18 @@ class TasksController < MyProfileController @ticket = Ticket.new(params[:ticket]) @ticket.requestor = profile if request.post? - @ticket.save! - redirect_to :action => 'index' + if @ticket.save + redirect_to :action => 'index' + end end end + def list_requested + @tasks = Task.find_all_by_requestor_id(profile.id) + end + + def ticket_details + @ticket = Ticket.find(:first, :conditions => ['(requestor_id = ? or target_id = ?) and id = ?', profile.id, profile.id, params[:id]]) + end + end diff --git a/app/models/task.rb b/app/models/task.rb index d034882..ab4012e 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -12,6 +12,7 @@ class Task < ActiveRecord::Base module Status + include GetText # the status of tasks just created ACTIVE = 1 @@ -20,6 +21,10 @@ class Task < ActiveRecord::Base # the status os a task that was successfully finished FINISHED = 3 + + def self.names + [nil, N_('Active'), N_('Cancelled'), N_('Finished')] + end end belongs_to :requestor, :class_name => 'Person', :foreign_key => :requestor_id diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 9b13217..ffc22a9 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -1,25 +1,4 @@ class Ticket < Task - - serialize :data, Hash - - def data - self[:data] ||= {} - end - - def title - data[:title] - end - - def title= value - data[:title] = value - end - - def description - data[:description] - end - - def description= value - data[:description] = value - end - + acts_as_having_settings :field => :data + settings_items :title, :description, :closing_statment end diff --git a/app/views/tasks/_ticket.rhtml b/app/views/tasks/_ticket.rhtml new file mode 100644 index 0000000..817dcae --- /dev/null +++ b/app/views/tasks/_ticket.rhtml @@ -0,0 +1,22 @@ +
+ <%= _('Created at %s by %s') % [@ticket.created_at.to_date, link_to(@ticket.requestor.name, @ticket.requestor.url)] %>
+ <%= _('Owner: %s') % link_to(@ticket.target.name, @ticket.target.url) %>
+
<%= _('Status: %s') % gettext(Task::Status.names[@ticket.status]) %>
+ +<%= _('Description: %s') % @ticket.description %>
+<%= _('Closing statement: %s') % @ticket.closing_statment %>
+<% end %> + +<% button_bar do %> + <%= button :back, _('Back'), :action => 'index' %> +<% end %> diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index 5bfc05d..dab7fce 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -121,4 +121,10 @@ class TasksControllerTest < Test::Unit::TestCase assert_equal profile, assigns(:ticket).requestor end + should 'list tasks that this profile created' do + task = Ticket.create!(:title => 'test', :requestor => profile) + get :list_requested, :profile => profile.identifier + + assert_includes assigns(:tasks), task + end end diff --git a/test/unit/ticket_test.rb b/test/unit/ticket_test.rb index d0d88f5..d4812a4 100644 --- a/test/unit/ticket_test.rb +++ b/test/unit/ticket_test.rb @@ -8,4 +8,5 @@ class TicketTest < ActiveSupport::TestCase assert_equal({:test => 'test'}, t.data) end + end -- libgit2 0.21.2