added newsletter controller

This commit is contained in:
Adrian Hinz 2019-12-02 14:41:24 +01:00
parent b93ed71e5f
commit a5e7d1c828
17 changed files with 110 additions and 8 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the Newsletter controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,16 @@
# frozen_string_literal: true
# Getting Newsletter emails
class NewsletterController < ApplicationController
def index; end
def new
@new_email = NewEmail.new
end
def create
@new_email = NewEmail.new
end
def destroy; end
end

View File

@ -74,8 +74,6 @@ class SiteController < ApplicationController
else else
return head(:bad_request) return head(:bad_request)
end end
end end

View File

@ -0,0 +1,2 @@
module NewsletterHelper
end

2
app/models/new_email.rb Normal file
View File

@ -0,0 +1,2 @@
class NewEmail < ApplicationRecord
end

View File

@ -36,12 +36,12 @@
<%= yield %> <%= yield %>
<!-- Copyright --> <!-- Copyright -->
<div id="copyright"> <div id="copyright">&copy; Akademia Technologii
&copy; Akademia Technologii 2018. | Design: <%= Time.now.year %>. | Design:
<a href="http://html5up.net">HTML5 UP</a> <a href="http://html5up.net">HTML5 UP</a>
</div> </div>
</div> </div>
<%= javascript_include_tag 'browser.min', 'breakpoints.min', 'util', 'main' %> <%= javascript_include_tag 'browser.min', 'breakpoints.min', 'util', 'main' %>
<%= yield :footer_scripts %> <%= yield :footer_scripts %>
</body> </body>
</html> </html>

View File

@ -0,0 +1,2 @@
<h1>Newsletter#create</h1>
<p>Find me in app/views/newsletter/create.html.erb</p>

View File

@ -0,0 +1,2 @@
<h1>Newsletter#index</h1>
<p>Find me in app/views/newsletter/index.html.erb</p>

View File

@ -0,0 +1,2 @@
<h1>Newsletter#new</h1>
<p>Find me in app/views/newsletter/new.html.erb</p>

View File

@ -10,12 +10,12 @@
Już niedługo powstanie tu <b>pierwszy w Polsce</b> internetowy kurs wzmacniania konstrukcji włóknami węglowymi CFRP. Jeżeli nie jesteś zainteresowany <b>nowoczesnymi metodami</b> wzmacniania budowli, <b>innowacyjnymi</b> materiałami, nie jesteś inżynierem albo technikiem budownictwa, architektem, bądź <b>wschodzącą gwiazdą</b> budowlanki na studiach, to nie klikaj w przycisk. Już niedługo powstanie tu <b>pierwszy w Polsce</b> internetowy kurs wzmacniania konstrukcji włóknami węglowymi CFRP. Jeżeli nie jesteś zainteresowany <b>nowoczesnymi metodami</b> wzmacniania budowli, <b>innowacyjnymi</b> materiałami, nie jesteś inżynierem albo technikiem budownictwa, architektem, bądź <b>wschodzącą gwiazdą</b> budowlanki na studiach, to nie klikaj w przycisk.
</p> </p>
<a href="#" class="button-large" style="color:white;">JESTEM CIEKAW</a> <a href="#" class="button-large" style="color:white;">JESTEM CIEKAW</a>
<a href="?wer=1">Wersja 1</a>|<a href="?wer=2">Wersja 2</a> <!--<a href="?wer=1">Wersja 1</a>|<a href="?wer=2">Wersja 2</a>-->
</section> </section>
</div> </div>
<iframe width="520" height="315" src="https://www.youtube.com/embed/tgbNymZ7vqY?controls=0" class="col-6 col-12-medium imp-medium"> <iframe width="520" src="https://www.youtube.com/embed/oL_Y1UEjKfo?controls=0" class="col-6 col-12-medium imp-medium">
</iframe> </iframe>
</div> </div>
</div> </div>

View File

@ -1,4 +1,5 @@
Rails.application.routes.draw do Rails.application.routes.draw do
resources :newsletter, only: %i[index new create destroy]
namespace :admin do namespace :admin do
namespace :articles do namespace :articles do
get 'all_page/publish' get 'all_page/publish'

View File

@ -0,0 +1,13 @@
class CreateNewEmails < ActiveRecord::Migration[5.1]
def change
create_table :new_emails do |t|
t.string :email
t.boolean :active
t.datetime :accepted
t.timestamps
end
add_index :new_emails, :email
add_index :new_emails, :active
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180119145343) do ActiveRecord::Schema.define(version: 20191202132743) do
create_table "admins", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t| create_table "admins", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
t.string "email", default: "", null: false t.string "email", default: "", null: false
@ -67,6 +67,16 @@ ActiveRecord::Schema.define(version: 20180119145343) do
t.index ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type" t.index ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type"
end end
create_table "new_emails", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
t.string "email"
t.boolean "active"
t.datetime "accepted"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["active"], name: "index_new_emails_on_active"
t.index ["email"], name: "index_new_emails_on_email"
end
create_table "published_pages", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t| create_table "published_pages", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
t.string "name", limit: 40, null: false t.string "name", limit: 40, null: false
t.string "title", null: false t.string "title", null: false
@ -74,6 +84,7 @@ ActiveRecord::Schema.define(version: 20180119145343) do
t.string "meta_description" t.string "meta_description"
t.integer "all_page_id", null: false t.integer "all_page_id", null: false
t.boolean "nofollow", default: false, null: false t.boolean "nofollow", default: false, null: false
t.integer "number_of_views", default: 0, null: false
t.integer "type_of", null: false t.integer "type_of", null: false
t.integer "article_id" t.integer "article_id"
t.integer "priority", default: 0, null: false t.integer "priority", default: 0, null: false
@ -83,6 +94,16 @@ ActiveRecord::Schema.define(version: 20180119145343) do
t.integer "created_by" t.integer "created_by"
t.timestamp "updated_at" t.timestamp "updated_at"
t.integer "updated_by" t.integer "updated_by"
t.index ["all_page_id"], name: "all_page_id"
t.index ["created_at"], name: "created_at"
t.index ["number_of_views"], name: "number_of_views"
t.index ["slug"], name: "slug"
t.index ["type_of"], name: "type_of"
end
create_table "sc_settings", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
t.integer "index_number_of_views", default: 0, null: false
t.integer "contact_number_of_views", default: 0, null: false
end end
end end

View File

@ -0,0 +1,19 @@
require 'test_helper'
class NewsletterControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get newsletter_index_url
assert_response :success
end
test "should get new" do
get newsletter_new_url
assert_response :success
end
test "should get create" do
get newsletter_create_url
assert_response :success
end
end

11
test/fixtures/new_emails.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
email: MyString
active: false
accepted: 2019-12-02 14:27:43
two:
email: MyString
active: false
accepted: 2019-12-02 14:27:43

View File

@ -0,0 +1,7 @@
require 'test_helper'
class NewEmailTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end