symphonia 2.2.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dbb027e9c0aabbd327fd90ec05a572978a20404790f27decfcecc1db39ca347
4
- data.tar.gz: 11320d1a38c2ebc7b95cee4020ac1192849c1473fbca1bf58508ce6c882c4e91
3
+ metadata.gz: a0e10863dd8e75d183b562258003c40246689f75f0d93ff6943934107be2abfd
4
+ data.tar.gz: a985e3482c1e9b9901de42e3c7f20dd7f322eec1a2695c0b42acfe33e8a2f99a
5
5
  SHA512:
6
- metadata.gz: 74731d7d000a1591b7046715a9118fd566a990c30900ddac2e6638a9799b8350f256a11a074e9e6b6eb2b3ed43911fb5785348bd0407644d2581450b4ab278be
7
- data.tar.gz: 5a38f655057548ff77d21b738aee676adfa25ac6117647e45ad00d80d41a1dee52f5c59af5ef2d86f8096d431f7ff9552486bbd1f99ab0ec05372460569399db
6
+ metadata.gz: 3fff9a1db7d9b89780d878198ba3d1a5fe59bcf924a2d5b2487a435120268ead124b8df1f5a80ba649e0f3b2dd25af17a31efba8f6c204d024dcc4add2793064
7
+ data.tar.gz: b5d316307dc2b6b894585beff086f66bbe8be9ca6d768d91c463c536a074002bebb5f354058d709607c38fa72dfdf0291d10a2f0c6f961d91a47955b44110910
@@ -2,32 +2,23 @@
2
2
  // *= require rails_bootstrap_forms
3
3
  // *= require bootstrap-datepicker3
4
4
  //@import "bootstrap-sprockets";
5
+
5
6
  @import "bootstrap";
6
7
  @import "bootstrap-datepicker3";
7
8
 
8
- //@media (min-width: $screen-sm) {
9
- // #internal_static_page_sign {
10
- // font-size: 20em;
11
- // }
12
- //}
13
- //
14
- //@media (min-width: $screen-md) {
15
- // #internal_static_page_sign {
16
- // font-size: 25em;
17
- // }
18
- //}
19
- //
20
- //@media (min-width: $screen-lg) {
21
- // #internal_static_page_sign {
22
- // font-size: 30em;
23
- // }
24
- //}
25
9
 
10
+ // fixed navbar
26
11
  body > .container {
27
- padding-top: 80px; // fixed navbar
12
+ padding-top: 80px;
13
+ }
14
+
15
+ @media print {
16
+ body > .container {
17
+ padding-top: 0 !important;
18
+ }
28
19
  }
20
+
29
21
  footer.footer {
30
- //position: absolute;
31
22
  height: 40px;
32
23
  line-height: 40px;
33
24
  bottom: 0;
@@ -113,9 +113,9 @@ module Symphonia
113
113
  @user = find_account_by_token(params.require(:id))
114
114
  return render_404 if @user.nil?
115
115
 
116
- if params[:password] && params[:password_confirmation]
116
+ if params[:password]# && params[:password_confirmation]
117
117
  @user.password = params[:password]
118
- @user.password_confirmation = params[:password_confirmation]
118
+ # @user.password_confirmation = params[:password_confirmation]
119
119
  end
120
120
 
121
121
  if @user.changed? && @user.save
@@ -166,4 +166,4 @@ module Symphonia
166
166
 
167
167
  end
168
168
 
169
- end
169
+ end
@@ -35,6 +35,7 @@ module Symphonia
35
35
 
36
36
  def destroy
37
37
  current_session && current_session.destroy
38
+ session.delete :return_to
38
39
  redirect_to '/', notice: t(:text_successfully_logout)
39
40
  end
40
41
 
@@ -53,12 +54,12 @@ module Symphonia
53
54
  path ||= Symphonia.config.after_login_path.presence
54
55
  path ||= get_first_menu_item_path(Symphonia::MenuManager.menu(:top_menu).values) || :admin_path
55
56
  case path
56
- when Symbol
57
- main_app.send(path)
58
- when Proc
59
- path.call(self)
60
- else
61
- path
57
+ when Symbol
58
+ main_app.send(path)
59
+ when Proc
60
+ path.call(self)
61
+ else
62
+ path
62
63
  end
63
64
  end
64
65
 
@@ -8,7 +8,7 @@ module Symphonia
8
8
  end
9
9
 
10
10
  def current_session
11
- current_user_session
11
+ current_user_session
12
12
  end
13
13
 
14
14
  end
@@ -25,12 +25,12 @@ module Symphonia
25
25
  key :'$ref', :User
26
26
  end
27
27
  end
28
- # response :default do
29
- # key :description, 'unexpected error'
30
- # schema do
31
- # key :'$ref', :ErrorModel
32
- # end
33
- # end
28
+ # response :default do
29
+ # key :description, 'unexpected error'
30
+ # schema do
31
+ # key :'$ref', :ErrorModel
32
+ # end
33
+ # end
34
34
  end
35
35
  end
36
36
 
@@ -49,7 +49,7 @@ module Symphonia
49
49
  @entities = @entities.page(params[:page])
50
50
  render layout: !request.xhr?
51
51
  end
52
- format.json { render json: @entities.all, only: %i[id]+Symphonia::User.registered_attributes.keys }
52
+ format.json { render json: @entities.all, only: %i[id] + Symphonia::User.registered_attributes.keys }
53
53
  end
54
54
  end
55
55
 
@@ -105,7 +105,7 @@ module Symphonia
105
105
  @user.edited_at = DateTime.now
106
106
  if @user.save
107
107
  format.html { redirect_back_or_default user_path(@user), notice: t(:text_updated) }
108
- format.any(:json ,:xml) { head :no_content }
108
+ format.any(:json, :xml) { head :no_content }
109
109
  else
110
110
  format.html do
111
111
  @roles = Symphonia::Role.all
@@ -122,7 +122,7 @@ module Symphonia
122
122
 
123
123
  respond_to do |format|
124
124
  format.html { redirect_to params[:back_url] || users_url }
125
- format.js { render js: "Symphonia.filters.removeRow('#{view_context.dom_id(@user)}')"}
125
+ format.js { render js: "Symphonia.filters.removeRow('#{view_context.dom_id(@user)}')" }
126
126
  format.json { head :no_content }
127
127
  end
128
128
  end
@@ -152,7 +152,7 @@ module Symphonia
152
152
  end
153
153
 
154
154
  def authorize
155
- if User.current.id == @user.try!(:id)
155
+ if User.current.logged_in? && User.current.id == @user&.id
156
156
  true
157
157
  else
158
158
  super
@@ -20,6 +20,13 @@ module Symphonia
20
20
 
21
21
  acts_as_authentic do |config|
22
22
  end
23
+ validates :email, uniqueness: { case_sensitive: false }
24
+ validates :password,
25
+ confirmation: { if: :require_password? },
26
+ length: {
27
+ minimum: 8,
28
+ if: :require_password?
29
+ }
23
30
 
24
31
  include UserManagement
25
32
 
@@ -47,6 +54,8 @@ module Symphonia
47
54
  end
48
55
  end
49
56
 
57
+ attr_writer :password_confirmation
58
+
50
59
  has_and_belongs_to_many :preferences, foreign_key: 'user_id'
51
60
 
52
61
  belongs_to :edited_by, class_name: 'Symphonia::User', required: false
@@ -57,6 +66,7 @@ module Symphonia
57
66
  scope :recipients_for, ->(notification) { joins(:preferences).where(preferences: { name: notification, type: 'Symphonia::EmailPreference' }) }
58
67
 
59
68
  scope :like, ->(q) { t = arel_table; where(t[:email].matches("%#{q}%").or(t[:first_name].matches("%#{q}%").or(t[:last_name].matches("%#{q}%")))) }
69
+ scope :admins, -> { where(admin: true) }
60
70
 
61
71
  alias_attribute :mail, :email
62
72
 
@@ -64,6 +74,9 @@ module Symphonia
64
74
  before_save do |model|
65
75
  Rails.cache.delete_matched('user_allowed_to*') if model.role_id_changed?
66
76
  end
77
+ before_validation do |model|
78
+ model.login ||= model.email
79
+ end
67
80
 
68
81
  def allowed_to?(action)
69
82
  return true if admin?
@@ -134,12 +147,8 @@ module Symphonia
134
147
  def persistence_token
135
148
  nil
136
149
  end
137
-
138
- def language
139
- Symphonia.config.default_locale || I18n.default_locale
140
- end
141
150
  end
142
151
 
143
152
  end
144
153
 
145
- end
154
+ end
@@ -33,7 +33,7 @@
33
33
  <slot id="flash_messages" name="flash_messages"><%= render_flash_messages.html_safe -%></slot>
34
34
  <%= yield %>
35
35
  </div>
36
- <footer class="footer">
36
+ <footer class="footer d-print-none">
37
37
  <div class="container text-center">
38
38
  &copy; Lukáš Pokorný
39
39
  <%= yield :footer %>
@@ -1,14 +1,7 @@
1
1
  <div class="row">
2
- <div class="col-xs-12 col-sm-6 col-md-3"><%= f.text_field :login, required: true %></div>
2
+ <!-- <div class="col-xs-12 col-sm-6 col-md-3"><%#= f.text_field :login, required: true %></div>-->
3
3
  <div class="col-xs-12 col-sm-6 col-md-3"><%= f.email_field :mail, required: true %></div>
4
4
  <div class="col-xs-12 col-sm-6 col-md-3"><%= f.text_field :first_name, required: true %></div>
5
5
  <div class="col-xs-12 col-sm-6 col-md-3"><%= f.text_field :last_name, required: true %></div>
6
- </div>
7
- <div class="row">
8
- <div class="col-xs-12 col-sm-6">
9
- <%= f.password_field :password, required: f.object.new_record?, prepend: icon('key') %>
10
- </div>
11
- <div class="col-xs-12 col-sm-6">
12
- <%= f.password_field :password_confirmation, required: f.object.new_record? %>
13
- </div>
6
+ <div class="col-xs-12 col-sm-6 col-md-3"><%= f.password_field :password, required: f.object.new_record?, prepend: icon('key') %></div>
14
7
  </div>
@@ -6,7 +6,7 @@
6
6
  <%= symphonia_form_tag(url: reset_password_account_path(params[:id]), method: 'put') do |f| %>
7
7
  <%= f.error_messages %>
8
8
  <%= f.password_field(:password, label: t(:'attributes.password'), required: true, wrapper_class: 'required') -%>
9
- <%= f.password_field(:password_confirmation, label: t(:'attributes.password_confirmation'), required: true, wrapper_class: 'required') -%>
9
+ <%#= f.password_field(:password_confirmation, label: t(:'attributes.password_confirmation'), required: true, wrapper_class: 'required') -%>
10
10
 
11
11
  <%= f.submit(t(:button_submit), class: 'btn btn-primary btn-block') -%>
12
12
 
@@ -0,0 +1,7 @@
1
+ class AddExternalIdToUsers < ActiveRecord::Migration[5.2]
2
+ def change
3
+ change_table :users do |t|
4
+ t.string :external_id, null: true
5
+ end
6
+ end
7
+ end
data/db/seeds.rb CHANGED
@@ -5,7 +5,7 @@ u.attributes = {
5
5
  last_name: 'Pokorný',
6
6
  email: 'luk4s.pokorny@gmail.com',
7
7
  password: 'admin',
8
- password_confirmation: 'admin',
8
+ # password_confirmation: 'admin',
9
9
  admin: true
10
10
  }
11
11
  u.single_access_token = SecureRandom.hex(20)
@@ -74,9 +74,8 @@ module Symphonia
74
74
  # private
75
75
 
76
76
  def set_locale
77
- client_lang = Array(params.fetch(:locale, nil).presence || session[:locale].presence || request.env['HTTP_ACCEPT_LANGUAGE'].to_s.split(',').collect { |l| l.scan(/^[a-z]{2}/) }.flatten)
78
- client_lang.unshift current_user.language if current_user.language
79
- @client_lang = client_lang.detect { |l| I18n.available_locales.include?(l.to_sym) }
77
+ client_lang = params.fetch(:locale, nil).presence || session[:locale].presence || request.env['HTTP_ACCEPT_LANGUAGE'].to_s.split(',').collect { |l| l.scan(/^[a-z]{2}/) }.flatten
78
+ @client_lang = Array(client_lang).detect { |l| I18n.available_locales.include?(l.to_sym) }
80
79
 
81
80
  I18n.locale = (@client_lang || I18n.default_locale)
82
81
  session[:locale] = I18n.locale
@@ -152,11 +151,13 @@ module Symphonia
152
151
 
153
152
  def current_user_session
154
153
  return @current_user_session if defined?(@current_user_session)
154
+
155
155
  @current_user_session = UserSession.find
156
156
  end
157
157
 
158
158
  def current_user
159
159
  return (Symphonia::User.current ||= @current_user) if defined?(@current_user)
160
+
160
161
  @current_user = current_user_session && current_user_session.user
161
162
  Symphonia::User.current = @current_user || Symphonia::User::Anonymous.new
162
163
  end
@@ -12,7 +12,7 @@ module Symphonia
12
12
 
13
13
  class_attribute :model
14
14
 
15
- # @param [nil, String] sort
15
+ # @param [nil, String] sort column_name:asc|desc
16
16
  # @param [Hash] filters
17
17
  # @param [nil, Array] columns
18
18
  def initialize(c = nil, sort: "", filters: {}, columns: nil, **options)
@@ -27,6 +27,10 @@ module Symphonia
27
27
  "#{first_name} #{last_name}"
28
28
  end
29
29
 
30
+ def name=(string)
31
+ self.first_name, self.last_name = string.split(" ")
32
+ end
33
+
30
34
  def status_new?
31
35
  pending?
32
36
  end
@@ -1,3 +1,3 @@
1
1
  module Symphonia
2
- VERSION = '2.2.1'
2
+ VERSION = '3.0.0'
3
3
  end
@@ -6,7 +6,7 @@ FactoryBot.define do
6
6
  login { email }
7
7
  admin { false }
8
8
  password { SecureRandom.hex(16) }
9
- password_confirmation { password }
9
+ # password_confirmation { password }
10
10
  last_request_at { Time.now }
11
11
 
12
12
  trait :admin do
@@ -18,7 +18,7 @@ FactoryBot.define do
18
18
  preference_names { [] }
19
19
  end
20
20
  after(:build) do |user, evaluator|
21
- user.preferences = evaluator.preference_names.collect { |pref_name| FactoryBot.create(:email_preference, name: pref_name) }
21
+ user.preferences = evaluator.preference_names.collect { |pref_name| Symphonia::EmailPreference.find_by(name: pref_name) || FactoryBot.create(:email_preference, name: pref_name) }
22
22
  end
23
23
  end
24
24
  factory :admin_user, traits: [:admin]
@@ -7,4 +7,10 @@ RSpec.describe Symphonia::User do
7
7
  it "#to_s" do
8
8
  expect(subject.to_s).to eq "#{subject.first_name} #{subject.last_name}"
9
9
  end
10
+
11
+ it "#name=" do
12
+ subject.name = "Tata smoula"
13
+ expect(subject.first_name).to eq "Tata"
14
+ expect(subject.last_name).to eq "smoula"
15
+ end
10
16
  end
data/spec/rails_helper.rb CHANGED
@@ -10,4 +10,4 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__)
10
10
  # Prevent database truncation if the environment is production
11
11
  abort('The Rails environment is running in production mode!') if Rails.env.production?
12
12
 
13
- require_relative 'spec_helper'
13
+ require_relative 'spec_helper'
@@ -34,10 +34,10 @@ describe Symphonia::AccountsController do
34
34
  end
35
35
 
36
36
  context 'pending' do
37
- let(:pending_user) { FactoryBot.create(:user, status: 'pending', password: 'heslo123', password_confirmation: 'heslo123')}
37
+ let(:pending_user) { FactoryBot.create(:user, status: 'pending', password: 'heslo123') }
38
38
 
39
39
  it '#login' do
40
- post symphonia.user_sessions_path, params: { login_session: { login: pending_user.login, password: 'heslo123' }}
40
+ post symphonia.user_sessions_path, params: { login_session: { login: pending_user.login, password: 'heslo123' } }
41
41
  expect(response).to have_http_status :success
42
42
  expect(Symphonia::User.current.id).not_to eq pending_user.id
43
43
  end
@@ -90,13 +90,13 @@ describe Symphonia::AccountsController do
90
90
  before { FactoryBot.create(:user, status: 'active'); user.update_columns(perishable_token: token) }
91
91
 
92
92
  it 'valid token' do
93
- put symphonia.reset_password_account_path(id: token, password: password, password_confirmation: password )
93
+ put symphonia.reset_password_account_path(id: token, password: password, password_confirmation: password)
94
94
  expect(response).to redirect_to symphonia.user_current_path
95
95
  expect(flash[:notice]).not_to be :blank
96
96
  end
97
97
 
98
98
  it 'invalid password' do
99
- put symphonia.reset_password_account_path(id: token, password: '12', password_confirmation: '11' )
99
+ put symphonia.reset_password_account_path(id: token, password: '12', password_confirmation: '11')
100
100
  expect(response).to have_http_status :success
101
101
  expect(flash[:notice]).to be_nil
102
102
  end
@@ -104,7 +104,6 @@ describe Symphonia::AccountsController do
104
104
  end
105
105
 
106
106
 
107
-
108
107
  end
109
108
 
110
109
  context 'form for user', logged: true do
@@ -115,4 +114,4 @@ describe Symphonia::AccountsController do
115
114
  end
116
115
  end
117
116
 
118
- end
117
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symphonia
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Pokorny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-28 00:00:00.000000000 Z
11
+ date: 2019-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.2'
41
- - !ruby/object:Gem::Dependency
42
- name: jbuilder
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.5'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.5'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rails-i18n
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +72,14 @@ dependencies:
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '4.4'
75
+ version: '5.0'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '4.4'
82
+ version: '5.0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: bootstrap
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -140,16 +126,16 @@ dependencies:
140
126
  name: font-awesome-rails
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
- - - ">="
129
+ - - "~>"
144
130
  - !ruby/object:Gem::Version
145
- version: '0'
131
+ version: 4.7.0.5
146
132
  type: :runtime
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
- - - ">="
136
+ - - "~>"
151
137
  - !ruby/object:Gem::Version
152
- version: '0'
138
+ version: 4.7.0.5
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: jquery-rails
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -565,6 +551,7 @@ files:
565
551
  - db/migrate/20130714140502_create_preferences.rb
566
552
  - db/migrate/20130828175114_create_attachments.rb
567
553
  - db/migrate/20141213204351_create_admin_modules.rb
554
+ - db/migrate/20190706130409_add_external_id_to_users.rb
568
555
  - db/seeds.rb
569
556
  - lib/generators/symphonia/entity_controller/entity_controller_generator.rb
570
557
  - lib/generators/symphonia/entity_controller/templates/controller.rb