Permalink
Browse files

Added ownership to short term and long term goals

Did the same thing I did for internship for long term and short term goals.
  • Loading branch information...
1 parent 17e0228 commit 8cd89eb9e63fb0cc18c021034eff9c78f77321d7 @kcalmes kcalmes committed Nov 18, 2011
View
2 app/controllers/long_term_goals_controller.rb
@@ -33,6 +33,8 @@ def show
def new
@long_term_goal = LongTermGoal.new
+ @long_term_goal.user = @current_user if @long_term_goal.user == nil
+
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @long_term_goal }
View
2 app/controllers/short_term_goals_controller.rb
@@ -56,6 +56,8 @@ def show
# GET /short_term_goals/new.xml
def new
@short_term_goal = ShortTermGoal.new
+
+ @short_term_goal.user = @current_user if @short_term_goal.user == nil
respond_to do |format|
format.html # new.html.erb
View
1 app/models/long_term_goal.rb
@@ -1,3 +1,4 @@
class LongTermGoal < ActiveRecord::Base
has_and_belongs_to_many :short_term_goals
+ belongs_to :user
end
View
1 app/models/short_term_goal.rb
@@ -2,6 +2,7 @@ class ShortTermGoal < ActiveRecord::Base
has_and_belongs_to_many :long_term_goals
has_many :tasks
belongs_to :tag
+ belongs_to :user
# TOKEN PROCESSING FOR AUTO-COMPLETE
def set_long_term_goals=(ids)
View
2 app/models/user.rb
@@ -4,6 +4,8 @@ class User < ActiveRecord::Base
has_and_belongs_to_many :tasks
has_many :internships
+ has_many :short_term_goals
+ has_many :long_term_goals
attr_accessor :display_name
View
1 app/views/internships/_form.html.erb
@@ -239,7 +239,6 @@
<div class="input_group">
<%= f.collection_select :user_id, User.all, :id, :net_id, {:selected => @internship.user.id} %>
</div>
- <img class="add_img select" model="providers">
</div>
<% else %>
<%= f.hidden_field :user_id %>
View
12 app/views/long_term_goals/_form.html.erb
@@ -27,5 +27,17 @@
<%= f.text_area :description %>
</div>
<% end %>
+ <%= theme_box(8, "Ownership", true) do %>
+ <% if can? :manage, :users %>
+ <div class="field">
+ <label>Net Id</label>
+ <div class="input_group">
+ <%= f.collection_select :user_id, User.all, :id, :net_id, {:selected => @long_term_goal.user.id} %>
+ </div>
+ </div>
+ <% else %>
+ <%= f.hidden_field :user_id %>
+ <% end %>
+ <% end %>
<% end %>
View
10 app/views/short_term_goals/_form.html.erb
@@ -124,6 +124,16 @@
<%= f.label :tag_id %><br />
<%= f.collection_select :tag_id, Tag.order(:name), :id, :name %>
</div>
+ <% if can? :manage, :users %>
+ <div class="field">
+ <label>Net Id</label>
+ <div class="input_group">
+ <%= f.collection_select :user_id, User.all, :id, :net_id, {:selected => @short_term_goal.user.id} %>
+ </div>
+ </div>
+ <% else %>
+ <%= f.hidden_field :user_id %>
+ <% end %>
</div>
<% content_tag :button, :type => :submit, :class => "green round_all" do %>
<%= image_tag "icons/small/white/Bended%20Arrow%20Right.png" %>
View
11 db/migrate/20111104184544_add_user_id_to_short_term_goals.rb
@@ -0,0 +1,11 @@
+class AddUserIdToShortTermGoals < ActiveRecord::Migration
+ def self.up
+ add_column :short_term_goals, :user_id, :integer
+ dave = User.find_by_net_id('dlw34');
+ ShortTermGoal.all.each { |f| f.update_attributes!(:user => dave) }
+ end
+
+ def self.down
+ remove_column :short_term_goals, :user_id
+ end
+end
View
11 db/migrate/20111118053112_add_user_id_to_long_term_goals.rb
@@ -0,0 +1,11 @@
+class AddUserIdToLongTermGoals < ActiveRecord::Migration
+ def self.up
+ add_column :long_term_goals, :user_id, :integer
+ dave = User.find_by_net_id('dlw34');
+ LongTermGoal.all.each { |f| f.update_attributes!(:user => dave) }
+ end
+
+ def self.down
+ remove_column :long_term_goals, :user_id
+ end
+end

0 comments on commit 8cd89eb

Please sign in to comment.