bcms_contact_us_module 1.0.1 → 1.1.2
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.
- data/app/controllers/cms/bcms_questions_controller.rb +2 -0
- data/app/models/{notifications.rb → bcms_notifications.rb} +1 -1
- data/app/models/{question.rb → bcms_question.rb} +2 -2
- data/app/portlets/contact_us_portlet.rb +3 -3
- data/app/views/cms/{questions → bcms_questions}/_form.html.erb +0 -0
- data/app/views/cms/{questions → bcms_questions}/render.html.erb +0 -0
- data/app/views/layouts/templates/default.html.erb +0 -1
- data/app/views/portlets/contact_us/render.html.erb +2 -2
- data/db/migrate/20101030141654_create_bcms_questions.rb +21 -0
- data/lib/bcms_contact_us_module/routes.rb +1 -1
- data/rails/init.rb +1 -0
- data/test/functional/cms/{questions_controller_test.rb → bcms_questions_controller_test.rb} +1 -1
- data/test/unit/bcms_notifications_test.rb +8 -0
- data/test/unit/{question_observer_test.rb → bcms_question_test.rb} +1 -1
- metadata +18 -20
- data/app/controllers/cms/questions_controller.rb +0 -2
- data/db/migrate/20101030141654_create_questions.rb +0 -21
- data/test/unit/models/question_test.rb +0 -9
- data/test/unit/notifications_test.rb +0 -12
@@ -1,11 +1,11 @@
|
|
1
|
-
class
|
1
|
+
class BcmsQuestion < ActiveRecord::Base
|
2
2
|
acts_as_content_block
|
3
3
|
|
4
4
|
# Pattern used to find real emails
|
5
5
|
EMAIL_PATTERN = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
|
6
6
|
|
7
7
|
# i18n messages stored in config/locales/en.yml
|
8
|
-
validates_presence_of :email
|
8
|
+
validates_presence_of :email, :name
|
9
9
|
validates_format_of :email, :with => EMAIL_PATTERN
|
10
10
|
|
11
11
|
# display_name is used in the admin secton of the cms to give our
|
@@ -5,12 +5,12 @@ class ContactUsPortlet < Portlet
|
|
5
5
|
|
6
6
|
def render
|
7
7
|
pmap = flash[instance_name] || params
|
8
|
-
@
|
9
|
-
@
|
8
|
+
@bcms_question = BcmsQuestion.new pmap[:bcms_question]
|
9
|
+
@bcms_question.errors.add_from_hash flash["#{instance_name}_errors"]
|
10
10
|
end
|
11
11
|
|
12
12
|
def action
|
13
|
-
question =
|
13
|
+
question = BcmsQuestion.new(params[:bcms_question] || {})
|
14
14
|
|
15
15
|
if question.save
|
16
16
|
|
File without changes
|
File without changes
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
<div class="contact_us_form">
|
4
4
|
|
5
|
-
<% form_for @
|
6
|
-
<%= error_messages_for :
|
5
|
+
<% form_for @bcms_question, :url => cms_handler_path(@portlet, "action") do |f| %>
|
6
|
+
<%= error_messages_for :bcms_question %>
|
7
7
|
|
8
8
|
<fieldset>
|
9
9
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateBcmsQuestions < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_content_table :bcms_questions do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :email
|
6
|
+
t.string :subject
|
7
|
+
t.text :message
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
ContentType.create!(:name => "BcmsQuestion", :group_name => "Administration")
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
ContentType.delete_all(['name = ?', 'BcmsQuestion'])
|
16
|
+
CategoryType.all(:conditions => ['name = ?', 'Question']).each(&:destroy)
|
17
|
+
#If you aren't creating a versioned table, be sure to comment this out.
|
18
|
+
drop_table :bcms_question_versions
|
19
|
+
drop_table :bcms_questions
|
20
|
+
end
|
21
|
+
end
|
data/rails/init.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcms_contact_us_module
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Freddy Andersen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-11 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -30,30 +30,29 @@ extra_rdoc_files:
|
|
30
30
|
- README.markdown
|
31
31
|
files:
|
32
32
|
- app/controllers/application_controller.rb
|
33
|
-
- app/controllers/cms/
|
33
|
+
- app/controllers/cms/bcms_questions_controller.rb
|
34
34
|
- app/helpers/application_helper.rb
|
35
|
-
- app/models/
|
36
|
-
- app/models/
|
35
|
+
- app/models/bcms_notifications.rb
|
36
|
+
- app/models/bcms_question.rb
|
37
37
|
- app/portlets/contact_us_portlet.rb
|
38
38
|
- app/portlets/helpers/contact_us_portlet_helper.rb
|
39
|
-
- app/views/cms/
|
40
|
-
- app/views/cms/
|
39
|
+
- app/views/cms/bcms_questions/_form.html.erb
|
40
|
+
- app/views/cms/bcms_questions/render.html.erb
|
41
41
|
- app/views/layouts/templates/default.html.erb
|
42
42
|
- app/views/portlets/contact_us/_form.html.erb
|
43
43
|
- app/views/portlets/contact_us/render.html.erb
|
44
|
-
- db/migrate/
|
44
|
+
- db/migrate/20101030141654_create_bcms_questions.rb
|
45
45
|
- lib/bcms_contact_us_module.rb
|
46
46
|
- lib/bcms_contact_us_module/routes.rb
|
47
47
|
- rails/init.rb
|
48
48
|
- LICENSE.txt
|
49
49
|
- README.markdown
|
50
|
-
- test/functional/cms/
|
50
|
+
- test/functional/cms/bcms_questions_controller_test.rb
|
51
51
|
- test/performance/browsing_test.rb
|
52
52
|
- test/test_helper.rb
|
53
|
-
- test/unit/
|
54
|
-
- test/unit/
|
53
|
+
- test/unit/bcms_notifications_test.rb
|
54
|
+
- test/unit/bcms_question_test.rb
|
55
55
|
- test/unit/portlets/contact_us_portlet_test.rb
|
56
|
-
- test/unit/question_observer_test.rb
|
57
56
|
has_rdoc: true
|
58
57
|
homepage: http://github.com/heimdull/bcms_contact_us_module
|
59
58
|
licenses: []
|
@@ -84,15 +83,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
83
|
requirements: []
|
85
84
|
|
86
85
|
rubyforge_project:
|
87
|
-
rubygems_version: 1.
|
86
|
+
rubygems_version: 1.4.1
|
88
87
|
signing_key:
|
89
88
|
specification_version: 3
|
90
89
|
summary: Contact Us portlet in BrowserCMS
|
91
90
|
test_files:
|
92
|
-
- test/functional/cms/
|
91
|
+
- test/functional/cms/bcms_questions_controller_test.rb
|
93
92
|
- test/performance/browsing_test.rb
|
94
93
|
- test/test_helper.rb
|
95
|
-
- test/unit/
|
96
|
-
- test/unit/
|
94
|
+
- test/unit/bcms_notifications_test.rb
|
95
|
+
- test/unit/bcms_question_test.rb
|
97
96
|
- test/unit/portlets/contact_us_portlet_test.rb
|
98
|
-
- test/unit/question_observer_test.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class CreateQuestions < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_content_table :questions do |t|
|
4
|
-
t.string :name
|
5
|
-
t.string :email
|
6
|
-
t.string :subject
|
7
|
-
t.text :message
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
ContentType.create!(:name => "Question", :group_name => "Administration")
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.down
|
15
|
-
ContentType.delete_all(['name = ?', 'Question'])
|
16
|
-
CategoryType.all(:conditions => ['name = ?', 'Question']).each(&:destroy)
|
17
|
-
#If you aren't creating a versioned table, be sure to comment this out.
|
18
|
-
drop_table :question_versions
|
19
|
-
drop_table :questions
|
20
|
-
end
|
21
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class NotificationsTest < ActionMailer::TestCase
|
4
|
-
test "new_question" do
|
5
|
-
@expected.subject = 'Notifications#new_question'
|
6
|
-
@expected.body = read_fixture('new_question')
|
7
|
-
@expected.date = Time.now
|
8
|
-
|
9
|
-
assert_equal @expected.encoded, Notifications.create_new_question(@expected.date).encoded
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|