subj_model 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +51 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/subj_model/user.rb +96 -0
- data/lib/subj_model/version.rb +3 -0
- data/lib/subj_model.rb +5 -0
- data/subj_model.gemspec +31 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eef50e837e5d8f1a74cddf7c1df7263013e9199d
|
4
|
+
data.tar.gz: ddf9eb54d7c43188a90fd491c0162e873b0c52e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fcbbdb5c83c863571bd585fa323adaa275deae7695a365b39ce71ec5712f074681b08b96339f2daf55fd866957933244c3ec765903a03dca301eea323ae8a637
|
7
|
+
data.tar.gz: 6dcbaf35a321b85d63d9c3a8c86a9c7573a0f8180b7ff0768956b3b71153e03ea1b8e76a43e65c23a1175272523aa6191e2a5af86619ee137ef5d8ae3bb98f12
|
data/.gitignore
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
*.rbc
|
11
|
+
capybara-*.html
|
12
|
+
.rspec
|
13
|
+
/log
|
14
|
+
/tmp
|
15
|
+
/db/*.sqlite3
|
16
|
+
/db/*.sqlite3-journal
|
17
|
+
/public/system
|
18
|
+
/coverage/
|
19
|
+
/spec/tmp
|
20
|
+
**.orig
|
21
|
+
rerun.txt
|
22
|
+
pickle-email-*.html
|
23
|
+
|
24
|
+
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
25
|
+
config/initializers/secret_token.rb
|
26
|
+
config/secrets.yml
|
27
|
+
|
28
|
+
# dotenv
|
29
|
+
# TODO Comment out this rule if environment variables can be committed
|
30
|
+
.env
|
31
|
+
|
32
|
+
## Environment normalization:
|
33
|
+
/.bundle
|
34
|
+
/vendor/bundle
|
35
|
+
|
36
|
+
# these should all be checked in to normalize the environment:
|
37
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
38
|
+
|
39
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
40
|
+
.rvmrc
|
41
|
+
|
42
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
43
|
+
/vendor/assets/bower_components
|
44
|
+
*.bowerrc
|
45
|
+
bower.json
|
46
|
+
|
47
|
+
# Ignore pow environment settings
|
48
|
+
.powenv
|
49
|
+
|
50
|
+
# Ignore Byebug command history file.
|
51
|
+
.byebug_history
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at mg@rademade.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# SubjModel
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/subj_model`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'subj_model'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install subj_model
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/subj_model. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "subj_model"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
module SubjModel
|
2
|
+
class User< ActiveRecord::Base
|
3
|
+
|
4
|
+
include ComprisingExternalId
|
5
|
+
include TypesSupport::UserTypes
|
6
|
+
include TypesSupport::CardReceiveTypes
|
7
|
+
include RademadeAdmin::UserModule
|
8
|
+
include SharedScopes
|
9
|
+
include ValuesChecker
|
10
|
+
|
11
|
+
enum user_type: USER_TYPES
|
12
|
+
enum card_receive_type: CARD_RECEIVE_TYPES
|
13
|
+
|
14
|
+
has_many :orders
|
15
|
+
has_many :user_specialization_approvals, dependent: :destroy
|
16
|
+
has_many :user_cards, dependent: :destroy
|
17
|
+
has_one :user_work_place, dependent: :destroy
|
18
|
+
has_many :user_delivery_addresses, dependent: :destroy
|
19
|
+
|
20
|
+
has_and_belongs_to_many :user_specializations
|
21
|
+
|
22
|
+
belongs_to :document_file
|
23
|
+
belongs_to :city
|
24
|
+
belongs_to :avatar, class_name: "DocumentFile"
|
25
|
+
|
26
|
+
validates :first_name, :last_name, presence: true,
|
27
|
+
on: :update,
|
28
|
+
unless: lambda { |user| user.legal_person? || user.skip_validations }
|
29
|
+
validates :email, uniqueness: { case_sensitive: false }, presence: true,
|
30
|
+
on: :update,
|
31
|
+
unless: :skip_validations
|
32
|
+
validates :phone, uniqueness: { case_sensitive: false }, presence: true,
|
33
|
+
on: :update,
|
34
|
+
unless: :skip_validations
|
35
|
+
validates :user_type, inclusion: { in: user_types.keys },
|
36
|
+
on: :update,
|
37
|
+
unless: :skip_validations
|
38
|
+
|
39
|
+
|
40
|
+
attr_accessor :skip_validations
|
41
|
+
|
42
|
+
scope :external_id, -> external_id do
|
43
|
+
external_id ? where(external_id: external_id) : User.none
|
44
|
+
end
|
45
|
+
|
46
|
+
def natural_person?
|
47
|
+
user_type == USER_TYPES.key(NATURAL_PERSON)
|
48
|
+
end
|
49
|
+
|
50
|
+
def legal_person?
|
51
|
+
user_type == USER_TYPES.key(LEGAL_PERSON)
|
52
|
+
end
|
53
|
+
|
54
|
+
def user_type=(value)
|
55
|
+
super(check_string_for_int(value))
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.get_by_email(email)
|
59
|
+
self.where(:email => email).first
|
60
|
+
end
|
61
|
+
|
62
|
+
def password=(password)
|
63
|
+
self.encrypted_password = encrypt_password(password) unless password.blank?
|
64
|
+
end
|
65
|
+
|
66
|
+
def password
|
67
|
+
self.encrypted_password
|
68
|
+
end
|
69
|
+
|
70
|
+
def valid_password?(password)
|
71
|
+
self.encrypted_password == encrypt_password(password)
|
72
|
+
end
|
73
|
+
|
74
|
+
def to_s
|
75
|
+
email
|
76
|
+
end
|
77
|
+
|
78
|
+
def admin?
|
79
|
+
self.user_type == 'админ'
|
80
|
+
end
|
81
|
+
|
82
|
+
def available_nomenclature_ids
|
83
|
+
Nomenclature.joins(access_groups: [user_specializations: :users]).where("users.id" => self.id).uniq.pluck(:id)
|
84
|
+
end
|
85
|
+
|
86
|
+
def available_categories_ids
|
87
|
+
Category.joins(:nomenclatures).where("nomenclatures.id IN (?) OR nomenclatures.is_professional=FALSE", available_nomenclature_ids).uniq.pluck(:id)
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def encrypt_password(password)
|
93
|
+
Digest::SHA1.hexdigest(password)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/subj_model.rb
ADDED
data/subj_model.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'subj_model/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "subj_model"
|
8
|
+
spec.version = SubjModel::VERSION
|
9
|
+
spec.authors = ["mihailsoft"]
|
10
|
+
spec.email = ["mg@rademade.com"]
|
11
|
+
|
12
|
+
spec.summary = "Its models gem"
|
13
|
+
spec.description = "Subj project"
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: subj_model
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mihailsoft
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Subj project
|
56
|
+
email:
|
57
|
+
- mg@rademade.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/subj_model.rb
|
72
|
+
- lib/subj_model/user.rb
|
73
|
+
- lib/subj_model/version.rb
|
74
|
+
- subj_model.gemspec
|
75
|
+
homepage:
|
76
|
+
licenses: []
|
77
|
+
metadata:
|
78
|
+
allowed_push_host: https://rubygems.org
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.5.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Its models gem
|
99
|
+
test_files: []
|