ish_models 0.0.30 → 0.0.31

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74ea9863f9415a3ed7040bb7d2795f3b83a91931
4
- data.tar.gz: 6feeb500ac6ad5c3aa91fd5171a49a93fd3fc9fe
3
+ metadata.gz: f16c35ed3fc7b44581a02934673f0280ce18890b
4
+ data.tar.gz: 70fb6987337c420c4389495c2a4b1b5fd87d5cdf
5
5
  SHA512:
6
- metadata.gz: dc094b80304bf175c24466a20a0140fa5a1943094ca6a2bc204102e188f6dcd0010c28ca3ce7a6445dadc20d80de651be162d3da6ec46d0c3dd13c1236367a96
7
- data.tar.gz: b2c5ac536916cbbb1c81b5673cc416f11e3af85e0a6cccca7e1d31daaf32b7c1ca5c862f09aaf5a1a29408d624b6fa249f9138f0a4542d8bc7b1baa9cd461218
6
+ metadata.gz: f51c9143bb4491e867a2b79908558c93d7efb5ba2c4cacaf643d9dc48fabc83ad8e1ccc953072c0887d5b269febe8e2a0382492947900132c56de06f9d15f3a5
7
+ data.tar.gz: 081082d09d1871da3ca18f84a691860ea599261c1a62f20ee4bc20f6adce692f9232e90dde733028ccd0d46f6120994e68bf3d2d146ed17a864e7f738aaad8c7
@@ -1,27 +1,18 @@
1
-
2
1
  require 'rails'
3
- require 'byebug'
2
+ # require 'byebug'
4
3
 
5
- File.open('/tmp/this', 'a') { |f| f.puts "#{Time.now} - load railtie" }
4
+ # File.open( '/tmp/this', 'a' ) { |f| f.puts "ish_models/railtie root: #{Rails.root}" }
5
+ # require Rails.root.join("config/initializers/00_s3.rb")
6
6
 
7
7
  module IshModels
8
8
  class Railtie < Rails::Railtie
9
9
 
10
- config.ish_models = ActiveSupport::OrderedOptions.new
10
+ # File.open( '/tmp/this', 'a' ) { |f| f.puts "ish_models/railtie config: #{config.inspect}" }
11
+ # File.open( '/tmp/this', 'a' ) { |f| f.puts "ish_models/railtie callback root: #{Rails.root}" }
11
12
 
12
13
  initializer "ish_models.configure" do |app|
13
- File.open('/tmp/this', 'a') { |f| f.puts "#{Time.now} - in railtie of ish_models" }
14
-
15
- IshModels.configure do |config|
16
- File.open('/tmp/this', 'a') { |f| f.puts "#{Time.now} - inside IshModels.configure inside... railtie" }
17
-
18
- require Rails.root.join("config/initializers/00_s3.rb")
19
-
20
- config.s3_cretendials = ::S3_CREDENTIALS
21
- end
22
-
23
- require Rails.root.join("config/initializers/00_s3.rb")
14
+ # File.open( '/tmp/this', 'a' ) { |f| f.puts "ish_models/railtie callback initializer root: #{Rails.root}" }
15
+ # require Rails.root.join("config/initializers/00_s3.rb")
24
16
  end
25
17
  end
26
18
  end
27
-
data/lib/ish_models.rb CHANGED
@@ -1,7 +1,8 @@
1
1
 
2
- require 'ish_models/configuration'
3
2
  require 'ish_models/railtie' if defined?(Rails)
3
+ # require 'ish_models/configuration'
4
4
 
5
+ =begin
5
6
  module IshModels
6
7
 
7
8
  class << self
@@ -16,6 +17,7 @@ module IshModels
16
17
  yield(configuration)
17
18
  end
18
19
  end
20
+ =end
19
21
 
20
22
  require 'ish_models/cache_key.rb'
21
23
  require 'ish_models/user.rb'
@@ -34,5 +36,6 @@ require 'public_item.rb'
34
36
  require 'report.rb'
35
37
  require 'site.rb'
36
38
  require 'tag.rb'
39
+ # require 'user.rb'
37
40
  require 'venue.rb'
38
41
  require 'video.rb'
data/lib/photo.rb CHANGED
@@ -31,7 +31,7 @@ class Photo
31
31
  field :is_trash, :type => Boolean, :default => false
32
32
  default_scope ->{ where({ :is_trash => false }) }
33
33
 
34
- File.open('/tmp/this', 'a') { |f| f.puts "#{Time.now} - inside photo.rb" }
34
+ # File.open('/tmp/this', 'a') { |f| f.puts "#{Time.now} - inside photo.rb" }
35
35
 
36
36
  has_mongoid_attached_file :photo,
37
37
  :styles => {
data/lib/user.rb ADDED
@@ -0,0 +1,122 @@
1
+
2
+ class User
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+
6
+ # Setup accessible (or protected) attributes for your model
7
+ # attr_accessible :email, :password, :password_confirmation, :remember_me
8
+
9
+ ## Database authenticatable
10
+ field :email, type: String, default: ""
11
+ validates :email, :presence => true, :uniqueness => true
12
+
13
+ field :encrypted_password, type: String, default: ""
14
+
15
+ ## Recoverable
16
+ field :reset_password_token, type: String
17
+ field :reset_password_sent_at, type: Time
18
+
19
+ ## Rememberable
20
+ field :remember_created_at, type: Time
21
+
22
+ ## Trackable
23
+ field :sign_in_count, type: Integer, default: 0
24
+ field :current_sign_in_at, type: Time
25
+ field :last_sign_in_at, type: Time
26
+ field :current_sign_in_ip, type: String
27
+ field :last_sign_in_ip, type: String
28
+
29
+ ## Confirmable
30
+ # field :confirmation_token, type: String
31
+ # field :confirmed_at, type: Time
32
+ # field :confirmation_sent_at, type: Time
33
+ # field :unconfirmed_email, type: String # Only if using reconfirmable
34
+
35
+ ## Lockable
36
+ # field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
37
+ # field :unlock_token, type: String # Only if unlock strategy is :email or :both
38
+ # field :locked_at, type: Time
39
+
40
+ # :recoverable, :trackable :rememberable,
41
+ # :token_authenticatable,
42
+ # :lockable, :timeoutable, :confirmable
43
+ devise :registerable, :validatable
44
+ devise :database_authenticatable, :authentication_keys => [ :email ]
45
+ # devise :omniauthable, :omniauth_providers => [ :facebook ]
46
+ # devise :encryptable, :encryptor => :sha1base64
47
+ #
48
+ #
49
+ # field :confirmed_at, :type => DateTime
50
+ # field :confirmation_token, :type => String
51
+ # field :confirmation_sent_at, :type => DateTime
52
+
53
+ field :username, :type => String
54
+ validates :username, :presence => true, :uniqueness => true
55
+
56
+ field :name, :type => String
57
+ validates :name, :presence => true
58
+
59
+ field :group_id, :type => Integer, :default => 3
60
+
61
+ field :scratchpad, :type => String
62
+ field :github_path, :type => String
63
+ field :facebook_path, :type => String
64
+ field :stackoverflow_path, :type => String
65
+
66
+ field :is_feature, :type => Boolean, :default => false
67
+ field :is_trash, :type => Boolean, :default => false
68
+
69
+ field :display_ads, :type => Boolean, :default => true
70
+ field :display_help, :type => Boolean, :default => true
71
+
72
+ has_many :reports
73
+ has_many :photos
74
+ has_many :user_profiles
75
+ has_many :galleries
76
+ has_many :videos
77
+
78
+ has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_user
79
+
80
+ has_and_belongs_to_many :viewable_photos, :class_name => 'Photo', :inverse_of => :viewer
81
+
82
+ belongs_to :guide_city, :class_name => 'City', :inverse_of => :guide
83
+ belongs_to :current_city, :class_name => 'City', :inverse_of => :city_users
84
+
85
+ def self.list conditions = { :is_trash => false }
86
+ out = self.where( conditions ).order_by( :name => :asc )
87
+ [['', nil]] + out.map { |item| [ item.name, item.id ] }
88
+ end
89
+
90
+ embeds_many :newsitems
91
+
92
+ def self.all
93
+ self.where( :is_trash => false ).order_by( :created_at => :desc )
94
+ end
95
+
96
+ def create_newsitem args = {}
97
+ unless args[:photo].blank?
98
+ n = Newsitem.new
99
+ n.photo = args[:photo]
100
+ n.descr = 'uploaded new photo on'
101
+ n.username = self.username
102
+ self.newsitems << n
103
+ self.save
104
+ end
105
+ end
106
+
107
+ def self.per_page
108
+ 16
109
+ end
110
+
111
+ def self.clear
112
+ if Rails.env.test?
113
+ User.unscoped.each { |u| u.remove }
114
+ end
115
+ end
116
+
117
+ def generate_auth_token
118
+ payload = { user_id: self.id }
119
+ AuthToken.encode(payload)
120
+ end
121
+
122
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 6.1.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: devise
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">"
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">"
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  description: models of ish
34
48
  email: victor@wasya.co
35
49
  executables: []
@@ -64,6 +78,7 @@ files:
64
78
  - lib/report.rb
65
79
  - lib/site.rb
66
80
  - lib/tag.rb
81
+ - lib/user.rb
67
82
  - lib/venue.rb
68
83
  - lib/video.rb
69
84
  homepage: http://wasya.co