Skip to content
This repository
  • 4 commits
  • 4 files changed
  • 0 comments
  • 2 contributors
Mar 11, 2013
Bertrand Chardon Fix for bug i[#45960641] Can't add new user aebb5a4
Bertrand Chardon Bug [#45960641] Can't add a new user 3d3cb8b
Mar 17, 2013
Rob Sterner Merge pull request #96 from rescuedcode/bug_add_new_user_doesnt_work_…
…on_staffplans

Bug add new user doesnt work on staffplans
8fca439
Mar 18, 2013
Rob Sterner Merge branch 'master' into cant_archive_users
Conflicts:
	app/assets/javascripts/models/membership.js.coffee
ae2b7fa
5  app/assets/javascripts/models/membership.js.coffee
... ...
@@ -1,6 +1,7 @@
1 1
 class window.StaffPlan.Models.Membership extends StaffPlan.Model
2  
-  initialize: (options) ->
  2
+  initialize: (attributes, options={}) ->
3 3
     @companyId = options.company_id
  4
+    @parent = options.parent
4 5
   
5 6
   url: ->
6 7
     mid = if @id then "/#{@id}" else ""
@@ -10,6 +11,8 @@ class window.StaffPlan.Models.Membership extends StaffPlan.Model
10 11
     membership:
11 12
       # Permissions
12 13
       permissions: @get("permissions") or []
  14
+      user_id: @get("user_id")
  15
+
13 16
       # Archived / Disabled
14 17
       archived: @get("archived") or false
15 18
       disabled: @get("disabled") or false
2  app/assets/javascripts/routers/staffplan.js.coffee
@@ -70,10 +70,8 @@ class StaffPlan.Routers.StaffPlan extends Support.SwappingRouter
70 70
     @swap userShow
71 71
 
72 72
   userNew: ->
73  
-    user = new window.StaffPlan.Models.User
74 73
     userNew = new window.StaffPlan.Views.Users.New
75 74
       router: @
76  
-      model: user
77 75
       collection: window.StaffPlan.users
78 76
     @swap userNew
79 77
  
5  app/assets/javascripts/views/users/new.js.coffee
@@ -39,9 +39,10 @@ class window.StaffPlan.Views.Users.New extends StaffPlan.View
39 39
     @collection.create userAttributes,
40 40
       success: (model, response) =>
41 41
         # We have a new user
42  
-        membership = new window.StaffPlan.Models.Membership
  42
+        membership = new window.StaffPlan.Models.Membership {user_id: model.id, company_id: window.StaffPlan.currentCompany.id},
43 43
           company_id: window.StaffPlan.currentCompany.id
44  
-        membership.save (_.extend membershipAttributes, {user_id: model.id}),
  44
+          parent: model
  45
+        membership.save membershipAttributes,
45 46
           success: (resource, response) ->
46 47
             # Set the newly saved membership on the user
47 48
             model.membership.set resource
4  app/models/user.rb
@@ -21,8 +21,8 @@ def for_company(company)
21 21
 
22 22
   after_update do |user|
23 23
     terminator = user.versions.last.try(:terminator)
24  
-    if terminator.present? and terminator.to_i != user.id
25  
-      User.find_by_id(terminator.to_i).update_timestamp!
  24
+    if terminator.present? && (terminator.to_i != user.id)
  25
+      User.where(:id => terminator.to_i).first.try(&:update_timestamp!)
26 26
     end
27 27
   end
28 28
 

No commit comments for this range

Something went wrong with that request. Please try again.