Fixed race condition if saving avatar image. Added image attribute in avatar observer controller.
This commit is contained in:
parent
054ad6ced3
commit
cb7d10fb1f
5 changed files with 17 additions and 14 deletions
|
@ -5,7 +5,7 @@ class App.ControllerGenericNew extends App.ControllerModal
|
||||||
headPrefix: 'New'
|
headPrefix: 'New'
|
||||||
|
|
||||||
content: =>
|
content: =>
|
||||||
@head = @pageData.object
|
@head = @pageData.head || @pageData.object
|
||||||
@controller = new App.ControllerForm(
|
@controller = new App.ControllerForm(
|
||||||
model: App[ @genericObject ]
|
model: App[ @genericObject ]
|
||||||
params: @item
|
params: @item
|
||||||
|
@ -53,7 +53,7 @@ class App.ControllerGenericEdit extends App.ControllerModal
|
||||||
|
|
||||||
content: =>
|
content: =>
|
||||||
@item = App[ @genericObject ].find( @id )
|
@item = App[ @genericObject ].find( @id )
|
||||||
@head = @pageData.object
|
@head = @pageData.head || @pageData.object
|
||||||
|
|
||||||
@controller = new App.ControllerForm(
|
@controller = new App.ControllerForm(
|
||||||
model: App[ @genericObject ]
|
model: App[ @genericObject ]
|
||||||
|
@ -1116,9 +1116,8 @@ class App.ObserverController extends App.Controller
|
||||||
if active
|
if active
|
||||||
currentAttributes[key] = object[key]
|
currentAttributes[key] = object[key]
|
||||||
if @observeNot
|
if @observeNot
|
||||||
attributes = object.attributes()
|
for key, value of object
|
||||||
for key, value of attributes
|
if !@observeNot[key] && !_.isFunction(value)
|
||||||
if !@observeNot[key]
|
|
||||||
currentAttributes[key] = value
|
currentAttributes[key] = value
|
||||||
|
|
||||||
if !@lastAttributres
|
if !@lastAttributres
|
||||||
|
|
|
@ -5,6 +5,7 @@ class App.WidgetAvatar extends App.ObserverController
|
||||||
firstname: true
|
firstname: true
|
||||||
lastname: true
|
lastname: true
|
||||||
email: true
|
email: true
|
||||||
|
image: true
|
||||||
|
|
||||||
render: (user) =>
|
render: (user) =>
|
||||||
@html(user.avatar @size, @position, undefined, false, false, @type)
|
@html(user.avatar @size, @position, undefined, false, false, @type)
|
||||||
|
|
|
@ -733,7 +733,8 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
||||||
)
|
)
|
||||||
|
|
||||||
# update user link
|
# update user link
|
||||||
current_user.update_attributes(image: avatar.store_hash)
|
user = User.find(current_user.id)
|
||||||
|
user.update_attributes(image: avatar.store_hash)
|
||||||
|
|
||||||
render json: { avatar: avatar }, status: :ok
|
render json: { avatar: avatar }, status: :ok
|
||||||
end
|
end
|
||||||
|
@ -751,7 +752,8 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
||||||
avatar = Avatar.set_default('User', current_user.id, params[:id])
|
avatar = Avatar.set_default('User', current_user.id, params[:id])
|
||||||
|
|
||||||
# update user link
|
# update user link
|
||||||
current_user.update_attributes(image: avatar.store_hash)
|
user = User.find(current_user.id)
|
||||||
|
user.update_attributes(image: avatar.store_hash)
|
||||||
|
|
||||||
render json: {}, status: :ok
|
render json: {}, status: :ok
|
||||||
end
|
end
|
||||||
|
@ -770,7 +772,8 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
||||||
|
|
||||||
# update user link
|
# update user link
|
||||||
avatar = Avatar.get_default('User', current_user.id)
|
avatar = Avatar.get_default('User', current_user.id)
|
||||||
current_user.update_attributes(image: avatar.store_hash)
|
user = User.find(current_user.id)
|
||||||
|
user.update_attributes(image: avatar.store_hash)
|
||||||
|
|
||||||
render json: {}, status: :ok
|
render json: {}, status: :ok
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue