ish_models 0.0.3 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app_model2.rb +33 -0
- data/lib/aux_model.rb +22 -0
- data/lib/city.rb +2 -2
- data/lib/gallery.rb +0 -1
- data/lib/ish_models.rb +13 -8
- data/lib/ish_models.rb~ +11 -0
- data/lib/newsitem.rb +50 -0
- data/lib/photo.rb +70 -0
- data/lib/public_item.rb +60 -0
- data/lib/report.rb +2 -2
- data/lib/site.rb +0 -1
- data/lib/venue.rb +2 -6
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8efda6f73dc85f020d688125566693bed7aca87
|
4
|
+
data.tar.gz: b907052ec21d45b83d0e084450c82dcf178ca0a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d410149815d472eef473f1a047a4c8dc54a11bcb7659484866e2503b9a284ef7bd2b44d742713d486a8ef69f64e36a153571725106a10bd9b743e7aa1a996995
|
7
|
+
data.tar.gz: 0857285ab83fca6aca9cf7304404767ee417ceac4c5ae62e55e2518af33aabd9256a10c8745d8e4357dd451c334a6cb35ed66c70c0cb758eed5d75bd7b46e1b3
|
data/lib/app_model2.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
class AppModel2
|
2
|
+
include ::Mongoid::Document
|
3
|
+
include ::Mongoid::Timestamps
|
4
|
+
|
5
|
+
field :is_feature, :type => Boolean, :default => false
|
6
|
+
field :is_public, :type => Boolean, :default => true
|
7
|
+
field :is_done, :type => Boolean, :default => false
|
8
|
+
field :is_trash, :type => Boolean, :default => false
|
9
|
+
field :is_anonymous, :type => Boolean, :default => false
|
10
|
+
|
11
|
+
scope :fresh, ->{ where({ :is_trash => false }) }
|
12
|
+
scope :trash, ->{ where({ :is_trash => true }) }
|
13
|
+
scope :public, ->{ where({ :is_public => true }) }
|
14
|
+
scope :done, ->{ where({ :is_done => true }) }
|
15
|
+
|
16
|
+
default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
|
17
|
+
|
18
|
+
field :x, :type => Float
|
19
|
+
field :y, :type => Float
|
20
|
+
|
21
|
+
def self.list conditions = { :is_trash => false }
|
22
|
+
out = self.where( conditions).order_by( :name => :asc )
|
23
|
+
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def puts! arg, label=""
|
29
|
+
puts "+++ +++ #{label}"
|
30
|
+
puts arg.inspect
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/aux_model.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
module AuxModel
|
3
|
+
|
4
|
+
def add_newsitem item
|
5
|
+
n = Newsitem.new
|
6
|
+
case item.class.name
|
7
|
+
when 'Video'
|
8
|
+
n.video_id = item.id
|
9
|
+
when 'Photo'
|
10
|
+
raise 'Not Implemented'
|
11
|
+
when 'Report'
|
12
|
+
raise 'Not Implemented'
|
13
|
+
when 'Gallery'
|
14
|
+
raise 'Not Implmented'
|
15
|
+
else
|
16
|
+
raise 'Not Implemented'
|
17
|
+
end
|
18
|
+
self.newsitems << n
|
19
|
+
self.save
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/lib/city.rb
CHANGED
data/lib/gallery.rb
CHANGED
data/lib/ish_models.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
|
2
|
+
require 'app_model2.rb'
|
3
|
+
require 'aux_model.rb'
|
2
4
|
require 'city.rb'
|
5
|
+
require 'country.rb'
|
6
|
+
require 'event.rb'
|
7
|
+
require 'feature.rb'
|
8
|
+
require 'gallery.rb'
|
9
|
+
require 'newsitem.rb'
|
10
|
+
require 'photo.rb'
|
11
|
+
require 'public_item.rb'
|
3
12
|
require 'report.rb'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
puts '+++ +++ Hello world from ish models!'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
=end
|
13
|
+
require 'site.rb'
|
14
|
+
require 'tag.rb'
|
15
|
+
require 'venue.rb'
|
16
|
+
require 'video.rb'
|
12
17
|
|
data/lib/ish_models.rb~
ADDED
data/lib/newsitem.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
class Newsitem
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
# include Mongoid::Paranoia
|
5
|
+
|
6
|
+
embedded_in :user
|
7
|
+
embedded_in :site
|
8
|
+
embedded_in :city
|
9
|
+
embedded_in :tag
|
10
|
+
|
11
|
+
belongs_to :photo
|
12
|
+
belongs_to :report
|
13
|
+
belongs_to :gallery
|
14
|
+
belongs_to :video
|
15
|
+
|
16
|
+
field :name, :type => String
|
17
|
+
field :descr, :type => String
|
18
|
+
field :image_path, :type => String
|
19
|
+
field :link_path, :type => String
|
20
|
+
field :username, :type => String # @TODO do I use this???
|
21
|
+
field :partial_name, :type => String, :default => nil # @deprecated, but let's not remove it.
|
22
|
+
|
23
|
+
field :weight, :type => Integer, :default => 10
|
24
|
+
field :n_upvotes, :type => Integer, :default => 0
|
25
|
+
field :n_downvotes, :type => Integer, :default => 0
|
26
|
+
field :upvoting_users, :type => Array, :default => []
|
27
|
+
field :downvoting_users, :type => Array, :default => []
|
28
|
+
field :is_feature, :type => Boolean, :default => false
|
29
|
+
|
30
|
+
default_scope ->{ order_by({ :created_at => :desc }) }
|
31
|
+
|
32
|
+
def self.from_params item
|
33
|
+
n = Newsitem.new
|
34
|
+
n.descr = item[:descr]
|
35
|
+
n.username = item[:username]
|
36
|
+
|
37
|
+
unless item[:report_id].blank?
|
38
|
+
n.report = Report.find item[:report_id]
|
39
|
+
end
|
40
|
+
|
41
|
+
unless item[:gallery_id].blank?
|
42
|
+
n.gallery = Gallery.find item[:gallery_id]
|
43
|
+
end
|
44
|
+
|
45
|
+
n.partial_name = item.partial_name unless item.partial_name.blank?
|
46
|
+
|
47
|
+
return n
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/lib/photo.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
class Photo
|
3
|
+
require 'aws-sdk'
|
4
|
+
require 'aws-sdk-v1'
|
5
|
+
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
include Mongoid::Paperclip
|
9
|
+
|
10
|
+
belongs_to :user, :inverse_of => :photos
|
11
|
+
validates :user, :presence => true
|
12
|
+
field :username, :type => String
|
13
|
+
|
14
|
+
has_and_belongs_to_many :viewers, :class_name => 'User', :inverse_of => :viewable_photos
|
15
|
+
|
16
|
+
belongs_to :profile_user, :class_name => 'User', :inverse_of => :profile_photo
|
17
|
+
belongs_to :profile_city, :class_name => 'City', :inverse_of => :profile_photo
|
18
|
+
belongs_to :profile_venue, :class_name => 'Venue', :inverse_of => :profile_photo
|
19
|
+
|
20
|
+
belongs_to :report
|
21
|
+
belongs_to :tag
|
22
|
+
belongs_to :venue
|
23
|
+
belongs_to :feature
|
24
|
+
belongs_to :gallery
|
25
|
+
|
26
|
+
field :name, :type => String
|
27
|
+
field :descr, :type => String
|
28
|
+
|
29
|
+
field :weight, :type => Integer, :default => 10
|
30
|
+
|
31
|
+
field :is_public, :type => Boolean, :default => true
|
32
|
+
field :is_trash, :type => Boolean, :default => false
|
33
|
+
|
34
|
+
# default_scope ->{ where({ :is_trash => false, :is_public => true }) }
|
35
|
+
default_scope ->{ where({ :is_trash => false }) }
|
36
|
+
|
37
|
+
has_mongoid_attached_file :photo,
|
38
|
+
:styles => {
|
39
|
+
:mini => '20x20#',
|
40
|
+
:thumb => "100x100#",
|
41
|
+
# :two_hundred => '200x200#',
|
42
|
+
:small => "400x400>",
|
43
|
+
# :small_square => "400x400#",
|
44
|
+
# :large_square => '950x650',
|
45
|
+
:large => '950x650>'
|
46
|
+
},
|
47
|
+
:storage => :s3,
|
48
|
+
:s3_credentials => ::S3_CREDENTIALS,
|
49
|
+
:path => "photos/:style/:id/:filename"
|
50
|
+
|
51
|
+
def self.n_per_manager_gallery
|
52
|
+
25
|
53
|
+
end
|
54
|
+
|
55
|
+
validates_attachment_content_type :photo, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
|
56
|
+
|
57
|
+
set_callback(:create, :before) do |doc|
|
58
|
+
# if doc.is_public
|
59
|
+
# Site.languages.each do |lang|
|
60
|
+
# n = Newsitem.new({
|
61
|
+
# # :descr => t('photos.new'),
|
62
|
+
# :photo => doc, :username => doc.user.username })
|
63
|
+
# Site.where( :domain => DOMAIN, :lang => lang ).first.newsitems << n
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
data/lib/public_item.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
class PublicItem
|
2
|
+
|
3
|
+
=begin
|
4
|
+
## let's try to make it work with newsitems, without publicitems yet.
|
5
|
+
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
|
9
|
+
belongs_to :site
|
10
|
+
belongs_to :city
|
11
|
+
belongs_to :tag
|
12
|
+
|
13
|
+
field :username
|
14
|
+
|
15
|
+
# acts as a report
|
16
|
+
# acts as a gallery
|
17
|
+
# acts as a video
|
18
|
+
has_many :photos
|
19
|
+
|
20
|
+
belongs_to :photo
|
21
|
+
belongs_to :report
|
22
|
+
belongs_to :gallery
|
23
|
+
belongs_to :video
|
24
|
+
|
25
|
+
field :name, :type => String
|
26
|
+
field :descr, :type => String
|
27
|
+
field :image_path, :type => String
|
28
|
+
field :link_path, :type => String
|
29
|
+
field :username, :type => String # @TODO do I use this???
|
30
|
+
field :partial_name, :type => String, :default => nil # @deprecated, but let's not remove it.
|
31
|
+
|
32
|
+
field :weight, :type => Integer, :default => 10
|
33
|
+
field :n_upvotes, :type => Integer, :default => 0
|
34
|
+
field :n_downvotes, :type => Integer, :default => 0
|
35
|
+
field :upvoting_users, :type => Array, :default => []
|
36
|
+
field :downvoting_users, :type => Array, :default => []
|
37
|
+
field :is_feature, :type => Boolean, :default => false
|
38
|
+
|
39
|
+
default_scope ->{ order_by({ :created_at => :desc }) }
|
40
|
+
|
41
|
+
def self.from_params item
|
42
|
+
n = Newsitem.new
|
43
|
+
n.descr = item[:descr]
|
44
|
+
n.username = item[:username]
|
45
|
+
|
46
|
+
unless item[:report_id].blank?
|
47
|
+
n.report = Report.find item[:report_id]
|
48
|
+
end
|
49
|
+
|
50
|
+
unless item[:gallery_id].blank?
|
51
|
+
n.gallery = Gallery.find item[:gallery_id]
|
52
|
+
end
|
53
|
+
|
54
|
+
n.partial_name = item.partial_name unless item.partial_name.blank?
|
55
|
+
|
56
|
+
return n
|
57
|
+
end
|
58
|
+
=end
|
59
|
+
|
60
|
+
end
|
data/lib/report.rb
CHANGED
data/lib/site.rb
CHANGED
data/lib/venue.rb
CHANGED
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.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
@@ -9,19 +9,45 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-05-10 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mongoid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.1.0
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 6.1.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 6.1.0
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 6.1.0
|
13
33
|
description: models of ish
|
14
34
|
email: victor@wasya.co
|
15
35
|
executables: []
|
16
36
|
extensions: []
|
17
37
|
extra_rdoc_files: []
|
18
38
|
files:
|
39
|
+
- lib/app_model2.rb
|
40
|
+
- lib/aux_model.rb
|
19
41
|
- lib/city.rb
|
20
42
|
- lib/country.rb
|
21
43
|
- lib/event.rb
|
22
44
|
- lib/feature.rb
|
23
45
|
- lib/gallery.rb
|
24
46
|
- lib/ish_models.rb
|
47
|
+
- lib/ish_models.rb~
|
48
|
+
- lib/newsitem.rb
|
49
|
+
- lib/photo.rb
|
50
|
+
- lib/public_item.rb
|
25
51
|
- lib/report.rb
|
26
52
|
- lib/site.rb
|
27
53
|
- lib/tag.rb
|