drg_cms 0.4.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +39 -0
- data/app/assets/images/drg_cms/add.png +0 -0
- data/app/assets/images/drg_cms/arrow_in.png +0 -0
- data/app/assets/images/drg_cms/arrow_out.png +0 -0
- data/app/assets/images/drg_cms/checkbox-checked.png +0 -0
- data/app/assets/images/drg_cms/checkbox-unchecked.png +0 -0
- data/app/assets/images/drg_cms/cols.png +0 -0
- data/app/assets/images/drg_cms/copy.png +0 -0
- data/app/assets/images/drg_cms/edit.png +0 -0
- data/app/assets/images/drg_cms/edit_design.png +0 -0
- data/app/assets/images/drg_cms/edit_page.png +0 -0
- data/app/assets/images/drg_cms/edit_site.png +0 -0
- data/app/assets/images/drg_cms/html.png +0 -0
- data/app/assets/images/drg_cms/pin.png +0 -0
- data/app/assets/images/drg_cms/printer.png +0 -0
- data/app/assets/images/drg_cms/reload.png +0 -0
- data/app/assets/images/drg_cms/search_16.png +0 -0
- data/app/assets/images/drg_cms/spinner.gif +0 -0
- data/app/assets/images/drg_cms/view_tile.png +0 -0
- data/app/assets/images/drg_cms/x.png +0 -0
- data/app/assets/javascripts/drg_cms/drg_cms.js +449 -0
- data/app/assets/javascripts/drg_cms/jquery-migrate.js +511 -0
- data/app/assets/javascripts/drg_cms/jquery.datetimepicker.js +1353 -0
- data/app/assets/javascripts/drg_cms/some_scripts.js +33 -0
- data/app/assets/javascripts/drg_cms_application.js +11 -0
- data/app/assets/javascripts/drg_cms_cms.js +28 -0
- data/app/assets/stylesheets/drg_cms/drg_cms.css +632 -0
- data/app/assets/stylesheets/drg_cms/jquery-ui.css +339 -0
- data/app/assets/stylesheets/drg_cms/jquery.datetimepicker.css +304 -0
- data/app/assets/stylesheets/drg_cms/th-bg.png +0 -0
- data/app/assets/stylesheets/drg_cms/theme.css +49 -0
- data/app/assets/stylesheets/drg_cms_application.css +12 -0
- data/app/assets/stylesheets/drg_cms_cms.css +26 -0
- data/app/controllers/cmsedit_controller.rb +673 -0
- data/app/controllers/dc_application_controller.rb +385 -0
- data/app/controllers/dc_at_the_beginning_controller.rb +120 -0
- data/app/controllers/dc_common_controller.rb +314 -0
- data/app/controllers/dc_mail_controller.rb +89 -0
- data/app/controllers/dc_main_controller.rb +40 -0
- data/app/controllers/drgcms_controls/dc_page_controls.rb +40 -0
- data/app/forms/all_options.yml +176 -0
- data/app/forms/cms_forms.yml +93 -0
- data/app/forms/cms_menu.yml +142 -0
- data/app/forms/dc_ad.yml +130 -0
- data/app/forms/dc_big_table.yml +59 -0
- data/app/forms/dc_big_table_locale.yml +41 -0
- data/app/forms/dc_big_table_value.yml +47 -0
- data/app/forms/dc_category.yml +57 -0
- data/app/forms/dc_design.yml +68 -0
- data/app/forms/dc_folder_permission.yml +49 -0
- data/app/forms/dc_forum_cat.yml +54 -0
- data/app/forms/dc_forum_forum.yml +53 -0
- data/app/forms/dc_forum_msg.yml +124 -0
- data/app/forms/dc_forum_privmsg.yml +125 -0
- data/app/forms/dc_forum_topic.yml +131 -0
- data/app/forms/dc_journal.yml +85 -0
- data/app/forms/dc_link.yml +55 -0
- data/app/forms/dc_mail.yml +88 -0
- data/app/forms/dc_mail_address.yml +56 -0
- data/app/forms/dc_mail_list.yml +44 -0
- data/app/forms/dc_mail_list_member.yml +42 -0
- data/app/forms/dc_menu.yml +62 -0
- data/app/forms/dc_menu_item.yml +81 -0
- data/app/forms/dc_page.yml +145 -0
- data/app/forms/dc_part.yml +102 -0
- data/app/forms/dc_permission.yml +50 -0
- data/app/forms/dc_piece.yml +105 -0
- data/app/forms/dc_policy.yml +57 -0
- data/app/forms/dc_policy_role.yml +42 -0
- data/app/forms/dc_policy_rule.yml +38 -0
- data/app/forms/dc_policy_rule_nocms.yml +38 -0
- data/app/forms/dc_poll.yml +113 -0
- data/app/forms/dc_poll_item.yml +76 -0
- data/app/forms/dc_simple_menu.yml +64 -0
- data/app/forms/dc_simple_menu_item.yml +80 -0
- data/app/forms/dc_site.yml +149 -0
- data/app/forms/dc_user.yml +142 -0
- data/app/forms/dc_user_role.yml +54 -0
- data/app/forms/drgcms_cms.yml +28 -0
- data/app/helpers/cmsedit_helper.rb +698 -0
- data/app/helpers/dc_ad_renderer.rb +206 -0
- data/app/helpers/dc_application_helper.rb +704 -0
- data/app/helpers/dc_big_menu_renderer.rb +180 -0
- data/app/helpers/dc_captcha_renderer.rb +100 -0
- data/app/helpers/dc_common_renderer.rb +132 -0
- data/app/helpers/dc_mail_renderer.rb +76 -0
- data/app/helpers/dc_menu_renderer.rb +143 -0
- data/app/helpers/dc_page_renderer.rb +80 -0
- data/app/helpers/dc_part_renderer.rb +162 -0
- data/app/helpers/dc_piece_renderer.rb +124 -0
- data/app/helpers/dc_poll_renderer.rb +219 -0
- data/app/helpers/dc_renderer.rb +56 -0
- data/app/helpers/dc_simple_menu_renderer.rb +244 -0
- data/app/helpers/drgcms_form_field.rb +863 -0
- data/app/models/__dc_global_data.rb +44 -0
- data/app/models/dc_ad.rb +52 -0
- data/app/models/dc_ad_stat.rb +34 -0
- data/app/models/dc_big_menu.rb +89 -0
- data/app/models/dc_big_table.rb +63 -0
- data/app/models/dc_big_table_locale.rb +35 -0
- data/app/models/dc_big_table_value.rb +38 -0
- data/app/models/dc_category.rb +48 -0
- data/app/models/dc_design.rb +48 -0
- data/app/models/dc_dummy.rb +30 -0
- data/app/models/dc_folder_permission.rb +43 -0
- data/app/models/dc_global_data.rb +44 -0
- data/app/models/dc_journal.rb +39 -0
- data/app/models/dc_key_value_store.rb +90 -0
- data/app/models/dc_link.rb +39 -0
- data/app/models/dc_mail.rb +64 -0
- data/app/models/dc_mail_address.rb +69 -0
- data/app/models/dc_mail_list.rb +48 -0
- data/app/models/dc_mail_list_member.rb +34 -0
- data/app/models/dc_menu.rb +59 -0
- data/app/models/dc_menu_item.rb +40 -0
- data/app/models/dc_page.rb +123 -0
- data/app/models/dc_part.rb +28 -0
- data/app/models/dc_permission.rb +58 -0
- data/app/models/dc_piece.rb +57 -0
- data/app/models/dc_policy.rb +94 -0
- data/app/models/dc_policy_role.rb +47 -0
- data/app/models/dc_policy_rule.rb +65 -0
- data/app/models/dc_poll.rb +46 -0
- data/app/models/dc_poll_item.rb +40 -0
- data/app/models/dc_sendmail.rb +48 -0
- data/app/models/dc_simple_menu.rb +58 -0
- data/app/models/dc_simple_menu_item.rb +39 -0
- data/app/models/dc_site.rb +92 -0
- data/app/models/dc_stat.rb +36 -0
- data/app/models/dc_user.rb +91 -0
- data/app/models/dc_user_role.rb +36 -0
- data/app/models/dc_visit.rb +35 -0
- data/app/views/cmsedit/_edit_stuff.html.erb +59 -0
- data/app/views/cmsedit/_edit_stuff.js.erb +6 -0
- data/app/views/cmsedit/_form.html.erb +21 -0
- data/app/views/cmsedit/_result.html.erb +20 -0
- data/app/views/cmsedit/edit.html.erb +6 -0
- data/app/views/cmsedit/error.html.erb +2 -0
- data/app/views/cmsedit/index.html.erb +6 -0
- data/app/views/cmsedit/new.html.erb +5 -0
- data/app/views/cmsedit/show.html.erb +21 -0
- data/app/views/dc_at_the_beginning/create.html.erb +9 -0
- data/app/views/dc_at_the_beginning/index.html.erb +19 -0
- data/app/views/dc_common/paste_clipboard.html.erb +17 -0
- data/app/views/dc_mail/subscribe.html.erb +7 -0
- data/app/views/dc_mail/unsubscribe.html.erb +19 -0
- data/app/views/layouts/cms.html.erb +17 -0
- data/app/views/layouts/cmsedit.html.erb +16 -0
- data/app/views/layouts/content.html.erb +16 -0
- data/config/initializers/kaminari_patch.rb +36 -0
- data/config/locales/datetimepicker.yml +13 -0
- data/config/locales/drgcms_en.yml +96 -0
- data/config/locales/drgcms_sl.yml +97 -0
- data/config/locales/en.yml +7 -0
- data/config/locales/kaminari.yml +26 -0
- data/config/locales/models_en.yml +790 -0
- data/config/locales/models_sl.yml +805 -0
- data/config/locales/mongoid_sl.yml +60 -0
- data/config/locales/sl.yml +211 -0
- data/config/routes.rb +2 -0
- data/drg_cms.gemspec +28 -0
- data/lib/drg_cms.rb +45 -0
- data/lib/drg_cms/engine.rb +30 -0
- data/lib/drg_cms/version.rb +3 -0
- data/lib/tasks/at_the_beginning.yml +26 -0
- data/lib/tasks/dc_cleanup.rake +94 -0
- data/lib/tasks/drg_cms_tasks.rake +118 -0
- data/lib/tasks/send_mail.rake +253 -0
- data/lib/tasks/site_statistics.rake +80 -0
- data/test/drg_cms_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- metadata +375 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
class DcDummy
|
25
|
+
include Mongoid::Document
|
26
|
+
|
27
|
+
def method_missing(m, *args, &block)
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
#########################################################################
|
25
|
+
#
|
26
|
+
#########################################################################
|
27
|
+
class DcFolderPermission
|
28
|
+
include Mongoid::Document
|
29
|
+
include Mongoid::Timestamps
|
30
|
+
|
31
|
+
field :folder_name, type: String
|
32
|
+
field :inherited, type: Boolean, default: true
|
33
|
+
field :is_default, type: Boolean, default: false
|
34
|
+
field :active, type: Boolean, default: true
|
35
|
+
|
36
|
+
embeds_many :dc_policy_rules
|
37
|
+
|
38
|
+
index( { folder_name: 1 }, { unique: true } )
|
39
|
+
|
40
|
+
validates :folder_name, presence: true
|
41
|
+
validates :folder_name, uniqueness: true
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
###########################################################################
|
25
|
+
# Based on knowledge found here
|
26
|
+
# http://jolierouge.net/2011/05/ruby-on-rails-session-in-models-not-so-evil-actually/
|
27
|
+
###########################################################################
|
28
|
+
class DcGlobalData
|
29
|
+
# This is a Locator/Broker class for global data that
|
30
|
+
# Needs to be accessible everywhere!
|
31
|
+
def self.method_missing(sym, *args, &block)
|
32
|
+
@@attrs ||= {}
|
33
|
+
sym = sym.to_s
|
34
|
+
if sym.include? "=" then
|
35
|
+
@@attrs[sym.gsub('=','')] = args.first
|
36
|
+
else
|
37
|
+
# if @@attrs[sym].class == Hash then
|
38
|
+
# return ValueProxy.new(@@attrs[sym])
|
39
|
+
# else
|
40
|
+
return @@attrs[sym]
|
41
|
+
# end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
class DcJournal
|
25
|
+
include Mongoid::Document
|
26
|
+
|
27
|
+
field :user_id, type: BSON::ObjectId
|
28
|
+
field :site_id, type: BSON::ObjectId
|
29
|
+
field :doc_id, type: BSON::ObjectId
|
30
|
+
field :operation, type: String
|
31
|
+
field :tables, type: String
|
32
|
+
field :ids, type: String
|
33
|
+
field :ip, type: String
|
34
|
+
field :time, type: DateTime
|
35
|
+
field :diff, type: String
|
36
|
+
|
37
|
+
index( { user_id: 1, time: -1 } )
|
38
|
+
index( { time: 1 } )
|
39
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
class DcKeyValueStore
|
25
|
+
include Mongoid::Document
|
26
|
+
|
27
|
+
field :key, type: String
|
28
|
+
field :value, type: String
|
29
|
+
|
30
|
+
index( { key: 1 }, { unique: true } )
|
31
|
+
|
32
|
+
###########################################################################
|
33
|
+
# Will return value incremented by 1 and update document with new value.
|
34
|
+
###########################################################################
|
35
|
+
def self.get_next_value(*keys)
|
36
|
+
doc = find_by(key: keys.join('-'))
|
37
|
+
value = (doc ? doc.value : '0').next
|
38
|
+
if doc
|
39
|
+
doc.value = value
|
40
|
+
doc.save!
|
41
|
+
else
|
42
|
+
create(key: keys.join('-'), value: value)
|
43
|
+
end
|
44
|
+
value
|
45
|
+
end
|
46
|
+
|
47
|
+
###########################################################################
|
48
|
+
# Will try to restore to previous value if value is not already incremented.
|
49
|
+
###########################################################################
|
50
|
+
def self.restore_value(value,*keys)
|
51
|
+
doc = find_by(key: keys.join('-'))
|
52
|
+
if value == doc.value
|
53
|
+
value = (value.to_i - 1).to_s
|
54
|
+
doc.value = value
|
55
|
+
doc.save!
|
56
|
+
return value
|
57
|
+
end
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
###########################################################################
|
62
|
+
#
|
63
|
+
###########################################################################
|
64
|
+
def self.peep_next_value(*keys)
|
65
|
+
doc = find_by(key: keys.join('-'))
|
66
|
+
(doc ? doc.value : '0').next
|
67
|
+
end
|
68
|
+
|
69
|
+
###########################################################################
|
70
|
+
#
|
71
|
+
###########################################################################
|
72
|
+
def self.get_value(*keys)
|
73
|
+
doc = find_by(key: keys.join('-'))
|
74
|
+
doc ? doc.value : nil
|
75
|
+
end
|
76
|
+
|
77
|
+
###########################################################################
|
78
|
+
#
|
79
|
+
###########################################################################
|
80
|
+
def self.set_value(value, *keys)
|
81
|
+
doc = find_by(key: keys.join('-'))
|
82
|
+
if doc
|
83
|
+
doc.value = value
|
84
|
+
doc.save!
|
85
|
+
else
|
86
|
+
create(key: keys.join('-'), value: value)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
class DcLink
|
24
|
+
include Mongoid::Document
|
25
|
+
include Mongoid::Timestamps
|
26
|
+
|
27
|
+
field :name, type: String
|
28
|
+
field :params, type: String
|
29
|
+
field :active, type: Boolean, default: true
|
30
|
+
field :page_id, type: BSON::ObjectId
|
31
|
+
field :created_by, type: BSON::ObjectId
|
32
|
+
field :updated_by, type: BSON::ObjectId
|
33
|
+
|
34
|
+
belongs_to :dc_site
|
35
|
+
|
36
|
+
index({ site_id: 1, name: 1 }, { unique: true })
|
37
|
+
|
38
|
+
validates :name, presence: true
|
39
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module DcMailCommon
|
25
|
+
extend ActiveSupport::Concern
|
26
|
+
included do
|
27
|
+
|
28
|
+
include Mongoid::Document
|
29
|
+
include Mongoid::Timestamps
|
30
|
+
|
31
|
+
field :subject, type: String
|
32
|
+
field :body, type: String
|
33
|
+
field :from, type: String
|
34
|
+
field :to_test, type: String
|
35
|
+
field :to_address, type: String
|
36
|
+
field :to_list, type: Array
|
37
|
+
field :schedule, type: DateTime
|
38
|
+
field :send_time, type: DateTime
|
39
|
+
field :status, type: Integer
|
40
|
+
field :css, type: String
|
41
|
+
|
42
|
+
field :created_by, type: BSON::ObjectId
|
43
|
+
field :updated_by, type: BSON::ObjectId
|
44
|
+
|
45
|
+
belongs_to :dc_site
|
46
|
+
|
47
|
+
index status: 1
|
48
|
+
|
49
|
+
validate :if_email_is_ok
|
50
|
+
|
51
|
+
def if_email_is_ok
|
52
|
+
errors.add(:from, I18n.t('drgcms.not_email')) unless DcMailAddress::dc_is_email?(from)
|
53
|
+
errors.add(:to_test, I18n.t('drgcms.not_email')) if to_test.to_s.size > 0 and !DcMailAddress::dc_is_email?(to_test)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
######################################################################
|
60
|
+
#
|
61
|
+
######################################################################
|
62
|
+
class DcMail
|
63
|
+
include DcMailCommon
|
64
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
class DcMailAddress
|
24
|
+
include Mongoid::Document
|
25
|
+
include Mongoid::Timestamps
|
26
|
+
|
27
|
+
field :email, type: String
|
28
|
+
field :reason, type: String
|
29
|
+
field :dc_user_id, type: BSON::ObjectId
|
30
|
+
field :active, type: Boolean, default: true
|
31
|
+
field :created_by, type: BSON::ObjectId
|
32
|
+
field :updated_by, type: BSON::ObjectId
|
33
|
+
|
34
|
+
embeds_many :dc_mail_list_members
|
35
|
+
belongs_to :dc_site
|
36
|
+
|
37
|
+
index( { 'dc_mail_list_members.dc_mail_list_id' => 1 } )
|
38
|
+
|
39
|
+
validate :if_email_is_ok
|
40
|
+
=begin
|
41
|
+
def if_email_is_ok
|
42
|
+
if dc_user_id.nil?
|
43
|
+
unless email.to_s =~ /^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
|
44
|
+
errors.add(:email, 'is not an email')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
=end
|
49
|
+
|
50
|
+
def if_email_is_ok
|
51
|
+
if dc_user_id.nil? and !DcMailAddress::dc_is_email?(email)
|
52
|
+
errors.add(:email, I18n.t('drgcms.not_email'))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
############################################################################
|
57
|
+
# Check if string contains valid e-mail address.
|
58
|
+
#
|
59
|
+
# @example usage from program
|
60
|
+
# dc_is_email?(some_email)
|
61
|
+
# eval: name4_id('site','name',@record['site_id'])
|
62
|
+
#
|
63
|
+
# @param [ email ] email address to be checked
|
64
|
+
############################################################################
|
65
|
+
def self.dc_is_email?(email)
|
66
|
+
email.to_s =~ /^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
class DcMailList
|
24
|
+
include Mongoid::Document
|
25
|
+
include Mongoid::Timestamps
|
26
|
+
|
27
|
+
field :name, type: String
|
28
|
+
field :description, type: String
|
29
|
+
field :params, type: String
|
30
|
+
field :active, type: Boolean, default: true
|
31
|
+
field :created_by, type: BSON::ObjectId
|
32
|
+
field :updated_by, type: BSON::ObjectId
|
33
|
+
|
34
|
+
belongs_to :dc_site
|
35
|
+
has_many :dc_mail_addresses
|
36
|
+
|
37
|
+
index({ site_id: 1, name: 1 }, { unique: true })
|
38
|
+
|
39
|
+
validates_length_of :name, minimum: 5
|
40
|
+
validates_length_of :description, minimum: 10
|
41
|
+
|
42
|
+
def self.choices4_mail_list
|
43
|
+
rez = []
|
44
|
+
all.each { |list| rez << [list.name, list._id] if list.active }
|
45
|
+
rez
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|