Skip to content

Commit

Permalink
Merge fa8fad0 into c93777d
Browse files Browse the repository at this point in the history
  • Loading branch information
moshinaan committed Mar 5, 2020
2 parents c93777d + fa8fad0 commit b173a73
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 19 deletions.
Expand Up @@ -4,6 +4,6 @@ class Tramway::Admin::WelcomeController < Tramway::Admin::ApplicationController
skip_before_action :check_available!

def index
self.instance_exec(&::Tramway::Admin.welcome_page_actions) if ::Tramway::Admin.welcome_page_actions.present?
instance_exec(&::Tramway::Admin.welcome_page_actions) if ::Tramway::Admin.welcome_page_actions.present?
end
end
2 changes: 1 addition & 1 deletion tramway-admin/lib/tramway/admin.rb
Expand Up @@ -55,7 +55,7 @@ def action_is_available?(record, project:, role:, model:, action:)
return false unless availability.present?
return true if availability.is_a? Symbol

return availability.values.first.call record
availability.values.first.call record
end

def select_actions(project:, role:, model:)
Expand Down
2 changes: 2 additions & 0 deletions tramway-admin/lib/tramway/admin/navbar.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Tramway::Admin::Navbar
def navbar_structure(*links)
@navbar_structure ||= links
Expand Down
2 changes: 1 addition & 1 deletion tramway-admin/lib/tramway/admin/records_models.rb
Expand Up @@ -7,7 +7,7 @@ def set_available_models(*models, project:, role: :admin)
@available_models[project][role] ||= {}
models.each do |model|
if model.class == Class
@available_models[project][role].merge! model => [ :index, :show, :update, :create, :destroy ]
@available_models[project][role].merge! model => %i[index show update create destroy]
elsif model.class == Hash
@available_models[project][role].merge! model
end
Expand Down
2 changes: 1 addition & 1 deletion tramway-admin/lib/tramway/admin/singleton_models.rb
Expand Up @@ -7,7 +7,7 @@ def set_singleton_models(*models, project:, role: :admin)
@singleton_models[project][role] ||= {}
models.each do |model|
if model.class == Class
@singleton_models[project][role].merge! model => [ :index, :show, :update, :create, :destroy ]
@singleton_models[project][role].merge! model => %i[index show update create destroy]
elsif model.class == Hash
@singleton_models[project][role].merge! model
end
Expand Down
2 changes: 2 additions & 0 deletions tramway-admin/lib/tramway/admin/welcome_page_actions.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Tramway
module Admin
module WelcomePageActions
Expand Down
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Tramway::Event::EventAsPageWithButtonDecorator < Tramway::Event::EventDecorator
def anchor
"event_#{object.id}"
Expand Down
@@ -1,12 +1,14 @@
# frozen_string_literal: true

module Tramway
module Core
module CopyToClipboardHelper
def copy_to_clipboard(id)
button_tag class: 'btn btn-info clipboard-btn',
data: { clipboard_action: 'copy', clipboard_target: "##{id}" },
style: 'margin-left: 15px' do
fa_icon 'copy'
end
data: { clipboard_action: 'copy', clipboard_target: "##{id}" },
style: 'margin-left: 15px' do
fa_icon 'copy'
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion tramway-core/app/uploaders/photo_uploader.rb
Expand Up @@ -12,7 +12,7 @@ def url
file.file.match(%r{/system/uploads/.*}).to_s
else
default_url = '/assets/tramway/core/mona_lisa_from_prado_square.jpg'
File.exists?(default_url) ? default_url : ''
File.exist?(default_url) ? default_url : ''
end
end

Expand Down
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Tramway::Event::ActionDecorator < Tramway::Core::ApplicationDecorator
class << self
delegate :human_action_state_event_name, to: :model_class
Expand All @@ -7,7 +9,7 @@ class << self
def name
"#{object.title} - #{date_view(object.deadline)} - #{state_machine_view(object, :action_state)}"
end

def action_state_button_color(event)
case event
when :do
Expand Down
Expand Up @@ -36,7 +36,7 @@ def list_attributes
decorate_association :partakings
decorate_association :partnerships
decorate_association :organizations
decorate_association :actions, as: :event, state_machines: [ :action_state ]
decorate_association :actions, as: :event, state_machines: [:action_state]

def background
object.photo
Expand Down
6 changes: 4 additions & 2 deletions tramway-event/app/forms/admin/tramway/event/action_form.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Admin::Tramway::Event::ActionForm < Tramway::Core::ApplicationForm
properties :title, :action_state_event, :deadline

Expand All @@ -6,8 +8,8 @@ class Admin::Tramway::Event::ActionForm < Tramway::Core::ApplicationForm
def initialize(object)
super(object).tap do
form_properties event: :association,
title: :string,
deadline: :date_picker
title: :string,
deadline: :date_picker
end
end
end
Expand Up @@ -12,7 +12,7 @@ def self.new(object)
SecureRandom.hex,
object.event,
participation_state_event: :default,
comment: :string,
comment: :string
).new object
else
super(object).tap do |obj|
Expand Down
4 changes: 3 additions & 1 deletion tramway-event/app/models/tramway/event/action.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Tramway::Event::Action < Tramway::Core::ApplicationRecord
belongs_to :event, class_name: 'Tramway::Event::Event'

Expand All @@ -15,7 +17,7 @@ class Tramway::Event::Action < Tramway::Core::ApplicationRecord
end

event :return do
transition [ :declined, :done ] => :must_be_done
transition %i[declined done] => :must_be_done
end
end
end
9 changes: 9 additions & 0 deletions tramway-event/app/models/tramway/event/event.rb
Expand Up @@ -3,6 +3,15 @@
class Tramway::Event::Event < ::Tramway::Event::ApplicationRecord
mount_uploader :photo, PhotoUploader

validate :check_dimensions

def check_dimensions
if photo.present?
errors.add :photo, :too_small_image if photo.width < 1920 || photo.height < 1080
errors.add :photo, :image_aspect_ratio if photo.height / photo.width == 16 / 9
end
end

has_many :participants, class_name: 'Tramway::Event::Participant'
has_many :participant_form_fields, class_name: 'Tramway::Event::ParticipantFormField'
has_many :sections, class_name: 'Tramway::Event::Section'
Expand Down
5 changes: 5 additions & 0 deletions tramway-event/config/locales/models.yml
Expand Up @@ -81,6 +81,11 @@ ru:
deadline: Дедлайн
errors:
models:
tramway/event/event:
attributes:
photo:
too_small_image: слишком маленькое (минимальный размер изображения 1920*1080)
image_aspect_ratio: не соответствует формату (соотношение сторон должно быть 16 на 9)
tramway/event/participant:
attributes:
default:
Expand Down
4 changes: 1 addition & 3 deletions tramway-export/lib/tramway/export.rb
Expand Up @@ -17,9 +17,7 @@ def exportable_model?(model_class, project:)
@exportable_models[project.to_sym]&.include? model_class
end

def exportable_models
@exportable_models
end
attr_reader :exportable_models
end
end
end
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Tramway::Landing::BlockLinkDecorator < ::Tramway::Landing::LinkDecorator
delegate :title, to: :object

Expand Down
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class Tramway::Landing::PageWithButtonDecorator < ::Tramway::Core::ApplicationDecorator
end
2 changes: 1 addition & 1 deletion tramway-user/app/decorators/tramway/user/user_decorator.rb
Expand Up @@ -11,7 +11,7 @@ def list_attributes
end

def show_attributes
[:email, :first_name, :last_name, :phone, :role, :created_at, :updated_at]
%i[email first_name last_name phone role created_at updated_at]
end
end

Expand Down
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AddPhoneToTramwayUserUsers < ActiveRecord::Migration[5.1]
def change
add_column :tramway_user_users, :phone, :text
Expand Down

0 comments on commit b173a73

Please sign in to comment.