Skip to content

Commit

Permalink
Merge branch 'release/0.3.13'
Browse files Browse the repository at this point in the history
* release/0.3.13:
  #269 fix tests
  #269 for now position
  #269 all positions
  #111 & #269 publicity of teams and non-exists for positions
  #269 genitive for primary
  #269 add positions exceptions
  #263 positions list
  #269 form for positions in admin
  #138 fix height for navbar
  • Loading branch information
kalashnikovisme committed Aug 11, 2015
2 parents 20e4793 + aeb93f6 commit d4eb72a
Show file tree
Hide file tree
Showing 38 changed files with 233 additions and 59 deletions.
3 changes: 0 additions & 3 deletions app/assets/javascripts/web/admin/members.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
10 changes: 10 additions & 0 deletions app/assets/stylesheets/web/admin/application.sass
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,13 @@ textarea
height: 100px
&:focus
height: 300px
.boolean
.checkbox
margin-top: 28px
margin-left: 5px
cursor: pointer
input[type="checkbox"].boolean
margin-top: 6px
label
&:not(.control-label)
margin-bottom: -25px
11 changes: 11 additions & 0 deletions app/assets/stylesheets/web/admin/members.sass
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
.position_fields
.btn.btn-danger
margin-top: 22px
float: right
div.input, div.boolean
width: 30%
float: left
margin-right: 1%
&.boolean
height: 64px
&.select
width: 100%
input, label, .input-group, .select2
float: left
1 change: 1 addition & 0 deletions app/assets/stylesheets/web/foundation/category-navbar.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import "foundation/functions";

.category-navbar-container {
height: 47px;
$topbar-height: rem-calc(47);

$topbar-bg-color: black;
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/web/admin/teams_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
class Web::Admin::TeamsController < Web::Admin::ApplicationController
before_filter :choose_members, only: [ :new, :edit ]

def index
@teams = Kaminari.paginate_array(Team.active.decorate).page params[:page]
@teams = {}
@teams[:active] = Kaminari.paginate_array(Team.active.decorate).page params[:page]
@teams[:unviewed] = Kaminari.paginate_array(Team.unviewed.decorate).page params[:page]
@teams[:removed] = Kaminari.paginate_array(Team.removed.decorate).page params[:page]
end

def new
Expand Down
17 changes: 15 additions & 2 deletions app/decorators/activity_line_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,21 @@ def short_body
"#{strip_tags(model.description)[0..50]}..."
end

def full_title
"#{I18n.t("enumerize.activity_line.activity_type.#{object.activity_type}")} «#{object.title}»"
def full_title(type_case = nil)
if object.activity_type.corporative?
if type_case
send type_case, object.title
else
object.title
end
else
type = I18n.t("enumerize.activity_line.activity_type.#{object.activity_type}")
if type_case
"#{send(type_case, type)} «#{object.title}»"
else
"#{type} «#{object.title}»"
end
end
end

def name
Expand Down
1 change: 1 addition & 0 deletions app/decorators/application_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class ApplicationDecorator < Draper::Decorator
include Rails.application.routes.url_helpers
include ActionView::Helpers
include RussianCases
end
9 changes: 6 additions & 3 deletions app/decorators/team_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ def short_description
"#{strip_tags(model.description)[0..50]}..."
end

def full_title
def full_title(type_case = nil)
team_type = I18n.t("activerecord.attributes.team.types.#{type.split(':').last.downcase}")
if object.is_departament?
"#{I18n.t("activerecord.attributes.team.types.#{type.split(':').last.downcase}")} в #{municipality}е"
"#{type_case ? send(type_case, team_type) : team_type} в #{instrumental(object.municipality)}"
elsif object.is_primary?
"#{type_case ? send(type_case, team_type) : team_type} в #{object.school}"
else
title
type_case ? send(type_case, title) : title
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/forms/member_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ class MemberForm < ApplicationForm
attributes :state_event, :parent_id, :school

association :positions do
attributes :title, :begin_date, :end_date, :member_id
attributes :title, :begin_date, :end_date, :member_id, :for_now
end
end
2 changes: 1 addition & 1 deletion app/forms/position_form.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class PositionForm < ActiveForm::Base
self.main_model = :position

attributes :title, :member_id, :begin_date, :end_date
attributes :title, :member_id, :begin_date, :end_date, :for_now
end
6 changes: 6 additions & 0 deletions app/helpers/web/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
module Web::ApplicationHelper
include PositionList

def positions_list
PositionList.list
end

def tel_tag(telephone, html_options = nil, &block)
link_to telephone, "tel:#{telephone}", html_options, &block
end
Expand Down
6 changes: 6 additions & 0 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Team < ActiveRecord::Base
include TeamScopes
extend Enumerize

enumerize :publicity, in: [ :visible, :hidden ], default: :hidden

state_machine :state, initial: :unviewed do
state :unviewed
state :active
Expand Down Expand Up @@ -39,6 +41,10 @@ def is_subdivision?
model_name == 'Team::Subdivision'
end

def is_primary?
model_name == 'Team::Primary'
end

#FIXME tags association
include Concerns::TagsHelper
def tags
Expand Down
1 change: 1 addition & 0 deletions app/scopes/activity_line_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module ActivityLineScopes

included do
scope :removed, -> { where state: :removed }
scope :active, -> { where state: :active }
scope :presented, -> { where.not(state: :removed).order('id ASC')}
scope :central_programs, -> { where activity_type: :central_program }
scope :local_projects, -> { where activity_type: :local_project }
Expand Down
2 changes: 1 addition & 1 deletion app/scopes/position_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module PositionScopes
extend ActiveSupport::Concern

included do
scope :for_now, -> { where end_date: :for_now }
scope :current_positions, -> { where for_now: 1 }
scope :last_held_position, -> { order('end_date DESC').first }
end
end
3 changes: 3 additions & 0 deletions app/scopes/team_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module TeamScopes

included do
scope :active, -> { where state: :active }
scope :unviewed, -> { where state: :unviewed }
scope :removed, -> { where state: :removed }
scope :visible, -> { where publicity: :visible }
scope :hidden, -> { where publicity: :hidden }
end
end
2 changes: 1 addition & 1 deletion app/views/web/admin/events/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
- else
= f.input :creator_id, as: :hidden, input_html: { value: current_user.id }
= f.association :activity_line, label_method: lambda { |activity_line| "#{I18n.t("enumerize.activity_line.activity_type.#{activity_line.activity_type}")} «#{activity_line.title}»" }, value_method: :id
.registrations
.registrations.nested
%h3
= t('.registrations')
-# FIXME @event_form.model.registrations.any? == true && @event_form.model.registrations.count == 0
Expand Down
13 changes: 6 additions & 7 deletions app/views/web/admin/members/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.col-lg-12
= render 'layouts/web/admin/shared/messages', object: @member_form
.row
.col-lg-6
.col-lg-12
= simple_form_for [:admin, @member_form], input_html: { class: 'form-horizontal' } do |f|
= f.input :first_name, as: :string, required: true
= f.input :patronymic, as: :string, required: true
Expand All @@ -30,12 +30,11 @@
= 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|
= position_form.input :title, as: :string
= position_form.input :begin_date, as: :date_picker
= position_form.input :end_date, as: :date_picker
= position_form.input :member_id, as: :hidden
-#= link_to_add_association t('.add_position'), f, :positions, data: { 'association-insertion-node' => 'this' }, class: 'btn btn-warning'
%h4
= t('.resume')
= f.simple_fields_for :positions do |position_form|
= render 'position_fields', f: position_form
= link_to_add_association t('.add_position'), f, :positions, data: { 'association-insertion-node' => 'this' }, class: 'btn btn-warning add_fields'
.actions
= f.button :submit, t('helpers.links.save'), class: 'btn-success'
= link_to t('helpers.links.back'), admin_members_path, class: 'btn btn-default'
5 changes: 3 additions & 2 deletions app/views/web/admin/members/_position_fields.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.position_fields
= f.input :title, as: :string
= f.input :title, as: :select, input_html: { class: :select2 }, collection: positions_list
= f.input :begin_date, as: :date_picker
= f.input :end_date, as: :date_picker
= f.input :for_now, as: :boolean, value: 1
= f.input :member_id, as: :hidden
= link_to_remove_association t('.remove_position'), f, class: 'btn btn-danger'
= link_to_remove_association 'X', f, class: 'btn btn-danger', data: { 'wrapper-class' => 'position_fields' }
1 change: 1 addition & 0 deletions app/views/web/admin/teams/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
= f.input :title, as: :string
= f.input :description, as: :ckeditor
= f.input :state, as: :hidden, input_html: { value: :active }
= f.input :publicity
= f.input :member_id, as: :select, collection: members_hash(@members), input_html: { class: :select2 }
= f.association :users, label_method: lambda { |member| "#{member.ticket} | #{member.first_name} #{member.last_name}" }, input_html: { class: :select2 }
= f.button :submit, class: 'btn-success', value: t('helpers.links.save')
Expand Down
2 changes: 2 additions & 0 deletions app/views/web/admin/teams/_teams_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
%th= model_class.human_attribute_name(:member)
%th= model_class.human_attribute_name(:type)
%th= model_class.human_attribute_name(:municipality)
%th= model_class.human_attribute_name(:publicity)
%th=t 'helpers.links.actions'
%tbody
- teams.each do |team|
Expand All @@ -17,6 +18,7 @@
%td= team.head_name
%td= team_types_name team.type
%td= team.municipality
%td= team.publicity
%td.actions
- if team.unviewed?
= link_to admin_team_path(team, team: { state: :confirmed }), method: :patch, class: 'btn btn-xs btn-success' do
Expand Down
12 changes: 10 additions & 2 deletions app/views/web/admin/teams/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
- model_class = Team
- tabs = @teams.keys
- title model_class.model_name.human.pluralize(:ru), :admin
.page-header
%h1
=t model_class.model_name.human.pluralize(:ru)
= link_to "#{t 'helpers.links.new'}", new_admin_team_path, class: 'btn btn-primary'
= render 'teams_list', teams: @teams
= link_to "#{t 'helpers.links.new'}", new_admin_team_path, class: 'btn btn-primary'
#tabs
%ul.nav.nav-tabs{ role: :tablist }
- tabs.each do |tab|
%li
= link_to tab_title(model_class, tab, @teams[tab].total_count), "##{tab}"
- tabs.each do |tab|
%div{ id: tab }
= render 'teams_list', teams: @teams[tab]
= link_to t('.new', default: t('helpers.links.new')), new_admin_team_path, class: 'btn btn-primary'
5 changes: 3 additions & 2 deletions app/views/web/members/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
.user-title-role
.user-title
= @member.short_name
-#.user-role
Ленивая жопа в МБОУ УФХ ЦЧЧ ЖЗ УК "Норма"
- @member.positions.current_positions.each do |position|
.user-role
= position.title
%blockquote.user-motto
= @member.motto
%hr.orange
Expand Down
2 changes: 2 additions & 0 deletions config/locales/ru/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ ru:
members:
form:
add_position: Добавить должность
resume: Резюме
position_fields:
for_now: до настоящего момента
remove_position: Убрать должность
tags:
form:
Expand Down
12 changes: 12 additions & 0 deletions config/locales/ru/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ ru:
title: Название
begin_date: Дата вступления в должность
end_date: Дата ухода с должности
for_now: до настоящего времени
event:
title: Название
description: Описание
Expand Down Expand Up @@ -127,6 +128,7 @@ ru:
municipality: Муниципальное образование
members: Члены команды
school: Учебное заведение
publicity: Публичность
types:
departament: Местное отделение
subdivision: Структурное подразделение
Expand Down Expand Up @@ -188,6 +190,12 @@ ru:
unviewed: Непросмотренные
active: Активные
removed: Удалённые
team:
state:
states:
unviewed: Непросмотренные
active: Активные
removed: Удалённые
errors:
models:
member:
Expand All @@ -214,6 +222,10 @@ ru:
role:
participant: Участник
organizer: Организатор
team:
publicity:
hidden: Скрытая
visible: Публичная
scopes:
event:
future: Грядущие
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20150811184106_add_publicity_to_team.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPublicityToTeam < ActiveRecord::Migration
def change
add_column :teams, :publicity, :text
end
end
7 changes: 7 additions & 0 deletions db/migrate/20150811224909_fix_position.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class FixPosition < ActiveRecord::Migration
def change
remove_column :positions, :end_date
add_column :positions, :end_date, :datetime
add_column :positions, :for_now, :text
end
end
13 changes: 6 additions & 7 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: 20150802220134) do
ActiveRecord::Schema.define(version: 20150811224909) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -188,9 +188,10 @@
t.text "title"
t.integer "member_id"
t.datetime "begin_date"
t.text "end_date", default: "for_now"
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 "end_date"
t.text "for_now"
end

create_table "tags", force: :cascade do |t|
Expand Down Expand Up @@ -233,16 +234,14 @@
t.text "type"
t.text "school"
t.integer "team_id"
t.text "publicity"
end

create_table "teams_users", id: false, force: :cascade do |t|
t.integer "team_id"
t.integer "user_id"
end

add_index "teams_users", ["team_id"], name: "index_teams_users_on_team_id", using: :btree
add_index "teams_users", ["user_id"], name: "index_teams_users_on_user_id", using: :btree

create_table "users", force: :cascade do |t|
t.text "email"
t.text "password_digest"
Expand Down
Loading

0 comments on commit d4eb72a

Please sign in to comment.