Skip to content

Commit

Permalink
Merge branch 'hotfix/0.3.8_fix.3'
Browse files Browse the repository at this point in the history
* hotfix/0.3.8_fix.3:
  fix user event participant
  fix comment order
  fix avatar on event registration
  • Loading branch information
kalashnikovisme committed Jul 27, 2015
2 parents 555e394 + 375a178 commit 6e1c4d9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
14 changes: 8 additions & 6 deletions app/assets/javascripts/web/events.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ $ ->
$participants_count_span = $('span#participants_count')
$participants_list = $('ul.participants')

participant_member_template = (participant, role) ->
participant_member_template = (participant, avatar_url, role) ->
"<li class='participant mic-member' id = 'participant_#{participant.id}'>
<a href='#{Routes.member_path(participant.ticket)}'>
<img src='#{participant.avatar.url}'>
<img src='#{avatar_url}'>
</a>
<section>
<a href='#{Routes.member_path(participant.ticket)}'>
Expand All @@ -19,9 +19,9 @@ $ ->
</section>
</li>"

participant_user_template = (participant, role) ->
participant_user_template = (participant, avatar_url, role) ->
"<li class='participant mic-member' id = 'participant_#{participant.id}'>
<img src='/default-man-icon.png'>
<img src='#{avatar_url}'>
<section>
<div class='name'>
#{participant.first_name} #{participant.last_name}
Expand All @@ -46,10 +46,12 @@ $ ->
add_event_participant = (response) ->
participant = JSON.parse response.participant
role = response.role
unless typeof response.avatar == 'string'
avatar_url = response.avatar.avatar.url
if participant.ticket == null
$participants_list.prepend participant_user_template participant, role
$participants_list.prepend participant_user_template participant, response.avatar, role
else
$participants_list.prepend participant_member_template participant, role
$participants_list.prepend participant_member_template participant, avatar_url, role
increase_participant_count()

remove_event_participant = (response) ->
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/events/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def create
if params[:event_registration][:user_id] == current_user.id.to_s
@event_form.submit params[:event_registration]
if @event_form.save
render json: { role: @event_form.model.role, participant: @event_form.model.user.to_json(only: [:id, :ticket, :first_name, :last_name, :short_name, :avatar]) }
render json: { role: @event_form.model.role, participant: @event_form.model.user.to_json(only: [:id, :ticket, :first_name, :last_name]), avatar: @event_form.model.user.decorate.element_avatar }
else
head :bad_request
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/web/news_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def show
@next_news = News.published.next @news.id
@same_events = ::EventDecorator.decorate_collection same_events
@popular_news = NewsDecorator.decorate_collection News.popular.first 6
@comments = @news.comments.presented.order('created_at ASC')
@comments = @news.comments.published
end

private
Expand Down
1 change: 1 addition & 0 deletions app/scopes/comment_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ module CommentScopes
scope :unviewed, -> { where(state: :unviewed).order('id DESC') }
scope :active, -> { where(state: :active).order('id DESC') }
scope :removed, -> { where(state: :removed).order('id DESC') }
scope :published, -> { where.not(state: :removed).order('created_at ASC') }
end
end

0 comments on commit 6e1c4d9

Please sign in to comment.