Skip to content

Commit

Permalink
Merge branch 'hotfix/0.2.17_fix.5'
Browse files Browse the repository at this point in the history
* hotfix/0.2.17_fix.5:
  edit navbar
  feedback only for signed_in
  many fixes
  • Loading branch information
kalashnikovisme committed Jun 24, 2015
2 parents 9030ac9 + e949714 commit 27649d7
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 48 deletions.
5 changes: 5 additions & 0 deletions app/assets/javascripts/application.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ $ ->
init_link_class = ->
$('.link').click ->
location.href = $(this).data('href')
$('.tr_link').each ->
$tr_link = $(this)
tds = $tr_link.children('td').not('.actions')
tds.click ->
location.href = $tr_link.data('href')
$('.slider-link').click ->
if $(this).hasClass 'slick-active'
location.href = $(this).data('href')
Expand Down
7 changes: 7 additions & 0 deletions app/assets/stylesheets/web/admin/application.sass
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,10 @@ span#cke_81.cke_toolbar
img
max-width: 100%
width: 200px

table
.btn-group
.btn.dropdown-toggle
padding: 5px 6px
.btn-xs
margin-right: 0
16 changes: 16 additions & 0 deletions app/models/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ class Member < User
end
end

state_machine :member_state, initial: :unviewed do
state :unviewed
state :confirmed
state :declined

event :confirm do
transition all => :confirmed
end
event :decline do
transition all => :declined
end
event :renew do
transition all => :unviewed
end
end

def has_auth_provider?(provider)
authentications.map do |authentication|
return authentication if authentication.provider == provider
Expand Down
24 changes: 20 additions & 4 deletions app/models/questionary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Questionary < Member
state :unviewed
state :confirmed
state :declined
state :on_the_trial
state :removed

event :confirm do
Expand All @@ -19,14 +18,31 @@ class Questionary < Member
event :decline do
transition all => :declined
end
event :put_on_the_trial do
transition all => :on_the_trial
end
event :remove do
transition all => :removed
end
event :restore do
transition removed: :unviewed
end
end

state_machine :member_state, initial: :unviewed do
state :unviewed
state :confirmed
state :on_the_trial
state :declined

event :confirm do
transition all => :confirmed
end
event :decline do
transition all => :declined
end
event :renew do
transition all => :unviewed
end
event :put_on_the_trial do
transition all => :on_the_trial
end
end
end
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def is_user?
model_name == 'User'
end

def is_active?
state == 'confirmed' || state == 'on_the_trial'
end

def generate_token
self.token = SecureHelper.generate_token
end
Expand Down
2 changes: 1 addition & 1 deletion app/scopes/member_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module MemberScopes
scope :confirmed, -> { where(state: :confirmed).order('id ASC') }
scope :declined, -> { where(state: :declined).order('id ASC') }
scope :removed, -> { where(state: :removed).order('id ASC') }
scope :unviewed, -> { where(state: :unviewed).order('id ASC') }
scope :unviewed, -> { where(state: :unviewed, type: 'Member').order('id ASC') }
scope :unavailable, -> { where(state: :unavailable).order('id ASC') }
end
end
2 changes: 1 addition & 1 deletion app/scopes/questionary_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module QuestionaryScopes
include Concerns::StateMachine

included do
scope :unviewed, -> { where state: :unviewed }
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 :removed, -> { where state: :removed }
Expand Down
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).order('id DESC') }
scope :unviewed, -> { where(state: :unviewed).where.not(type: 'Member', email: nil).order('id DESC') }
scope :confirmed, -> { where(state: :confirmed).order('id DESC') }
scope :declined, -> { where(state: :declined).order('id DESC') }
end
Expand Down
31 changes: 21 additions & 10 deletions app/views/layouts/web/admin/_navbar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,37 @@
= Member.model_name.human.pluralize(:ru)
= menu_item admin_questionaries_path do
= Questionary.model_name.human.pluralize(:ru)
= menu_item admin_news_index_path do
= News.model_name.human.pluralize(:ru)
- if current_user.role.admin?
%li.dropdown
%a.dropdown-toggle{ href: '#', data: { toggle: :dropdown } }
= t('.activity')
%ul.dropdown-menu
= menu_item admin_events_path do
= Event.model_name.human.pluralize(:ru)
= menu_item admin_activity_lines_path do
= ActivityLine.model_name.human.pluralize(:ru)
= menu_item admin_teams_path do
= Team.model_name.human.pluralize(:ru)
= menu_item admin_news_index_path do
= News.model_name.human.pluralize(:ru)
= menu_item admin_articles_path do
= Article.model_name.human.pluralize(:ru)
= menu_item admin_categories_path do
= Category.model_name.human.pluralize(:ru)
= menu_item admin_events_path do
= Event.model_name.human.pluralize(:ru)
- if current_user.role.admin?
= menu_item admin_activity_lines_path do
= ActivityLine.model_name.human.pluralize(:ru)
= menu_item admin_banners_path do
= Banner.model_name.human.pluralize(:ru)
= menu_item admin_teams_path do
= Team.model_name.human.pluralize(:ru)
= menu_item admin_documents_path do
= Document.model_name.human.pluralize(:ru)
= menu_item admin_feedback_index_path do
= Feedback.model_name.human.pluralize(:ru)
- elsif current_user.role.author?
= menu_item admin_events_path do
= Event.model_name.human.pluralize(:ru)
= menu_item admin_news_index_path do
= News.model_name.human.pluralize(:ru)
= menu_item admin_articles_path do
= Article.model_name.human.pluralize(:ru)
= menu_item admin_categories_path do
= Category.model_name.human.pluralize(:ru)
- if current_user.role.admin?
%ul.nav.navbar-nav.navbar-right
= menu_item admin_unviewed_index_path do
Expand Down
25 changes: 13 additions & 12 deletions app/views/layouts/web/shared/_feedback_modal.html.haml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#feedbackModal.reveal-modal{"aria-hidden" => "true", "aria-labelledby" => "firstModalTitle", "data-reveal" => "", role: "dialog"}
%h2#feedbackModalTitle
Нашли ошибку?
%p
Опишите её, пожалуйста.
= simple_form_for @feedback, remote: true, url: { controller: '/api/feedback', action: :create } do |f|
= f.input :text
= f.input :url, as: :hidden, input_html: { value: request.original_url }
- if signed_in?
= f.input :user_id, as: :hidden, input_html: { value: current_user.id }
= f.button :submit, t('helpers.links.send')
%a.close-reveal-modal{"aria-label" => "Close"} ×
- if signed_in?
#feedbackModal.reveal-modal{"aria-hidden" => "true", "aria-labelledby" => "firstModalTitle", "data-reveal" => "", role: "dialog"}
%h2#feedbackModalTitle
Нашли ошибку?
%p
Опишите её, пожалуйста.
= simple_form_for @feedback, remote: true, url: { controller: '/api/feedback', action: :create } do |f|
= f.input :text
= f.input :url, as: :hidden, input_html: { value: request.original_url }
- if signed_in?
= f.input :user_id, as: :hidden, input_html: { value: current_user.id }
= f.button :submit, t('helpers.links.send')
%a.close-reveal-modal{"aria-label" => "Close"} ×
9 changes: 5 additions & 4 deletions app/views/layouts/web/shared/_navbar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- if signed_in?
- if current_user.role.admin?
%li
= link_to admin_path do
= link_to admin_unviewed_index_path do
.inner
%i.fa.fa-info-circle
= @notification_count
Expand Down Expand Up @@ -75,6 +75,7 @@
- @first_category.articles.confirmed.each do |article|
= link_to article.title, article_path(article)
%li
= link_to '#', data: { 'reveal-id' => 'feedbackModal' } do
.inner
Нашли ошибку?
- if signed_in? && current_user.state == 'confirmed'
= link_to '#', data: { 'reveal-id' => 'feedbackModal' } do
.inner
Нашли ошибку?
1 change: 1 addition & 0 deletions app/views/web/admin/members/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
= f.input :avatar, label: false, as: :jasny_file_preview_upload
- unless @member_form.model.unavailable?
= f.input :state_event, as: :state_event
= f.input :member_state_event, as: :state_event
= f.input :role
= f.input :parent_id, as: :select, collection: members_hash(@members), input_html: { class: :select2 }
-#= f.simple_fields_for :positions do |position_form|
Expand Down
4 changes: 2 additions & 2 deletions app/views/web/admin/members/_members_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
-#%td= member.main_position_title
%td= member.place
%td.actions
- unless member.confirmed?
= link_to admin_member_path(member, member: { state: :confirmed }), method: :patch, class: 'btn btn-success btn-xs' do
- unless member.member_state == 'confirmed'
= link_to admin_member_path(member, member: { state: :confirmed, member_state: :confirmed }), method: :patch, class: 'btn btn-success btn-xs' do
%span.glyphicon.glyphicon-ok
= link_to edit_admin_member_path(member), class: 'btn btn-warning btn-xs' do
%span.glyphicon.glyphicon-pencil
Expand Down
2 changes: 2 additions & 0 deletions app/views/web/admin/questionaries/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
= f.input :avatar, as: :file
= f.input :want_to_do
= f.input :experience
= f.input :state_event, as: :state_event
= f.input :member_state_event, as: :state_event
= f.button :submit, t('helpers.links.save'), class: 'btn-success'
= link_to t('helpers.links.back'), admin_questionaries_path, class: 'btn btn-default'
18 changes: 9 additions & 9 deletions app/views/web/admin/questionaries/_questionaries_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
%th= t 'helpers.links.actions'
%tbody
- questionaries.each do |questionary|
%tr.link{ class: state_color(questionary), data: { href: edit_admin_questionary_path(questionary) } }
%tr.tr_link{ class: state_color(questionary), data: { href: edit_admin_questionary_path(questionary) } }
%td= questionary.id
%td= questionary.avatar
%td= image_tag questionary.avatar.small
%td= questionary.full_name
%td= questionary.place
%td=l questionary.created_at
%td.actions
%td.actions{ style: 'width: 147px' }
.btn-group
= link_to '#', class: 'btn btn-xs btn-success' do
%span.glyphicon.glyphicon-ok
= link_to '#', class: 'btn btn-xs btn-success dropdown-toggle', data: { toggle: :dropdown }, aria: { expanded: false } do
%span.glyphicon.glyphicon-triangle-bottom
%ul.dropdown-menu
- if questionary.unviewed?
- if questionary.member_state == 'unviewed'
%li
= link_to t('state_machines.questionary.state.events.put_on_the_trial'), admin_questionary_path(questionary, questionary: { state: :put_on_the_trial }), method: :put
- unless questionary.confirmed?
= link_to t('state_machines.questionary.state.events.put_on_the_trial'), admin_questionary_path(questionary, questionary: { member_state: :on_the_trial }), method: :put
- unless questionary.member_state == 'confirmed'
%li
= link_to t('state_machines.questionary.state.events.confirm'), admin_questionary_path(questionary, questionary: { state: :put_on_the_trial }), method: :put
= link_to t('state_machines.questionary.state.events.confirm'), admin_questionary_path(questionary, questionary: { member_state: :confirmed }), method: :put
= link_to edit_admin_questionary_path(questionary), class: 'btn btn-warning btn-xs' do
%span.glyphicon.glyphicon-pencil
.btn-group
Expand All @@ -40,7 +40,7 @@
%ul.dropdown-menu
%li
= link_to t('helpers.links.destroy'), admin_questionary_path(questionary), method: :delete
- unless questionary.declined?
- unless questionary.member_state == :declined
%li
= link_to t('helpers.links.decline'), admin_questionary_path(questionary, questionary: { state: :declined }), method: :patch
= link_to t('helpers.links.decline'), admin_questionary_path(questionary, questionary: { member_state: :declined }), method: :patch
= paginate questionaries, theme: 'twitter-bootstrap-3'
2 changes: 1 addition & 1 deletion app/views/web/events/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
%button.join-button.mic-press-button{ value: 'out', data: { event_id: @event.id, user_id: current_user.id } }
= t('.i_attend')
- else
- if signed_in? && current_user.confirmed?
- if signed_in? && current_user.is_active?
%button.join-button.mic-press-button{ value: 'join', data: { event_id: @event.id, user_id: current_user.id } }
= t('.attend')
- elsif signed_in? && current_user.is_user? && current_user.unviewed?
Expand Down
1 change: 1 addition & 0 deletions config/locales/ru/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ru:
create_place: Добавить место
navbar:
people: Люди
activity: Деятельность
hints:
admin:
user:
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20150624113404_add_member_state_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMemberStateToUsers < ActiveRecord::Migration
def change
add_column :users, :member_state, :text, default: :unviewed
end
end
7 changes: 4 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150622210131) do
ActiveRecord::Schema.define(version: 20150624113404) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -251,11 +251,12 @@
t.text "experience"
t.text "want_to_do"
t.string "type"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "join_date"
t.text "token"
t.text "school"
t.text "member_state", default: "unviewed"
end

end

0 comments on commit 27649d7

Please sign in to comment.