Skip to content

Commit

Permalink
Merge branch 'release/0.2.24'
Browse files Browse the repository at this point in the history
* release/0.2.24:
  update for questionaries
  update users scopes
  • Loading branch information
kalashnikovisme committed Jul 6, 2015
2 parents 96c32ab + dbc9f35 commit 756044f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions app/controllers/web/admin/questionaries_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class Web::Admin::QuestionariesController < Web::Admin::ApplicationController
def index
@unviewed_questionaries = Kaminari.paginate_array(Questionary.unviewed.decorate).page params[:page]
@on_the_trial_questionaries = Kaminari.paginate_array(Questionary.on_the_trial.decorate).page params[:page]
@declined_questionaries = Kaminari.paginate_array(Questionary.declined.decorate).page params[:page]
@questionaries = {}
@questionaries[:on_the_trial] = Kaminari.paginate_array(Questionary.on_the_trial.decorate).page params[:page]
@questionaries[:unviewed] = Kaminari.paginate_array(Questionary.unviewed.decorate).page params[:page]
@questionaries[:declined] = Kaminari.paginate_array(Questionary.declined.decorate).page params[:page]
end

def new
Expand All @@ -27,7 +28,6 @@ def update
@questionary_form = QuestionaryForm.find_with_model params[:id]
@questionary_form.submit params[:questionary]
if @questionary_form.save
@questionary_form.member.confirm if @questionary_form.model.confirmed?
redirect_to admin_questionaries_path
else
render action: :edit
Expand Down
2 changes: 1 addition & 1 deletion app/scopes/questionary_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module QuestionaryScopes
included do
scope :unviewed, -> { where(member_state: :unviewed).order('id DESC') }
scope :presented, -> { where.not(state: :removed) }
scope :on_the_trial, -> { where state: :on_the_trial }
scope :on_the_trial, -> { where member_state: :on_the_trial }
scope :removed, -> { where state: :removed }
end
end
2 changes: 1 addition & 1 deletion app/scopes/user_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module UserScopes
scope :admins, -> { where role: :admin }
scope :presented, -> { where.not(state: :removed).order('id DESC') }
scope :removed, -> { where(state: :removed).order('id DESC') }
scope :unviewed, -> { where(state: :unviewed, type: nil).where.not(email: nil).order('id DESC') }
scope :unviewed, -> { where(state: :unviewed, type: nil).where.not(email: nil, state: :removed).order('id DESC') }
scope :confirmed, -> { where(state: :confirmed).order('id DESC') }
scope :declined, -> { where(state: :declined).order('id DESC') }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%tr.tr_link{ class: state_color(questionary), data: { href: edit_admin_questionary_path(questionary) } }
%td= questionary.id
%td= image_tag questionary.avatar.small
%td= questionary.full_name
%td= link_to questionary.full_name, edit_admin_questionary_path(questionary)
%td= questionary.place
%td=l questionary.created_at
%td.actions{ style: 'width: 147px' }
Expand Down
13 changes: 5 additions & 8 deletions app/views/web/admin/questionaries/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- model_class = Questionary
- tabs = [ :on_the_trial, :unviewed, :declined ]
- title model_class.model_name.human.pluralize(:ru), :admin
- tabs = @questionaries.keys
.page-header
%h1
= model_class.model_name.human.pluralize(:ru)
Expand All @@ -9,11 +9,8 @@
%ul.nav.nav-tabs{ role: :tablist }
- tabs.each do |tab|
%li
= link_to t("state_machines.#{model_class.model_name.to_s.downcase}.state.states.#{tab}").pluralize(:ru), "##{tab}"
#on_the_trial
= render 'questionaries_list', questionaries: @on_the_trial_questionaries
#unviewed
= render 'questionaries_list', questionaries: @unviewed_questionaries
#declined
= render 'questionaries_list', questionaries: @declined_questionaries
= link_to tab_title(model_class, tab, @questionaries[tab].total_count), "##{tab}"
- tabs.each do |tab|
%div{ id: tab }
= render 'questionaries_list', questionaries: @questionaries[tab]
= link_to t('.new', default: t('helpers.links.new')), new_admin_questionary_path, class: 'btn btn-primary'

0 comments on commit 756044f

Please sign in to comment.