added new stuff and fix errors

This commit is contained in:
Adrian Hinz 2022-04-04 17:03:16 +02:00
parent 33e6eec5e3
commit 90a317a4ac
34 changed files with 323 additions and 64 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1004 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 KiB

View File

@ -0,0 +1,33 @@
.mainer-header {
position: relative;
min-height: 800px;
background: url("/assets/main_kalendarz1.png") no-repeat center center fixed;
background-size: cover;
}
.mainer-header .overlay {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(33, 37, 41, 0.85);
color: #fff;
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}

View File

@ -20,7 +20,16 @@ class HomeController < ApplicationController
.point_desc.end_date_asc.page(params[:page])
end
def contact; end
def contact
@email_message = EmailMessage.new
end
def register_contact
@email_message = EmailMessage.new(email_messages_params)
return unless @email_message.save
SendEmailJob.perform_later(@email_message.id)
end
def show
@dotation = Dotation.friendly.find(params[:id])
@ -74,4 +83,9 @@ class HomeController < ApplicationController
ammount_price: params[:ammount_price]
}
end
# Only allow a list of trusted parameters through.
def email_messages_params
params.require(:email_message).permit(:subject, :email, :message)
end
end

View File

@ -71,6 +71,6 @@ class PartnersController < ApplicationController
# Only allow a list of trusted parameters through.
def partner_params
params.require(:partner).permit(:name, :description, :logo)
params.require(:partner).permit(:name, :description, :logo, :link_url)
end
end

View File

@ -0,0 +1,12 @@
# frozen_string_literal: true
class SendEmailJob < ApplicationJob
queue_as :default
def perform(email_message_id)
email_message = EmailMessage.where(id: email_message_id).first
return if email_message.blank?
NotifyEmailMailer.with(email: email_message_id).contact_page.deliver
end
end

View File

@ -0,0 +1,22 @@
# frozen_string_literal: true
# Mailer for dotations
class NotifyEmailMailer < ApplicationMailer
default from: 'kalendarzdotacji@gmail.com'
def contact_page
@email_message = EmailMessage.where(id: params[:email]).first
# @emailfilter = FilterForEmail.find(params[:emailfilter])
mail(to: APP_CONFIG['notify_email'], subject: 'Nowa wiadomość ze strony kalendarzdotacji.pl')
end
def contact_dotation
@email_filter = FilterForEmail.where(id: params[:email_filter]).first
@dotation = Dotation.where(id: params[:dotation_id]).first
@email_params = {
i: @email_filter.email,
k: @email_filter.unique_name
}
mail(to: @email_filter.email, subject: 'Pojawiła się nowa dotacja')
end
end

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
# Email messages
class EmailMessage < ApplicationRecord
# == Constants ============================================================
# == Attributes ===========================================================
# == Extensions ===========================================================
# == Relationships ========================================================
# == Validations ==========================================================
validates :subject, presence: true
validates :email, presence: true
validates :message, presence: true
# == Scopes ===============================================================
# == Callbacks ============================================================
# == Class Methods ========================================================
# == Instance Methods =====================================================
end

View File

@ -0,0 +1,22 @@
<div class="card-body">
<%= form_with(model: email_message, url: '/home/register_contact', method: :post, remote: true, id: 'contact_form_form') do |form| %>
<div id="email_mess_div">
<%= render '/shared/errors_list', error_object: email_message %>
</div>
<div class="form-group">
<%= form.label :subject %>
<%= form.text_field :subject, class: 'form-control', placeholder: 'Podaj temat' %>
</div>
<div class="form-group">
<%= form.label :email %>
<%= form.email_field :email, class: 'form-control', placeholder: 'Wprowadź email' %>
</div>
<div class="form-group">
<%= form.label :message %>
<%= form.text_area :message, class: 'form-control', placeholder: 'Wprowadź treść wiadomości' %>
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-primary">Wyślij</button>
</div>
<% end %>

View File

@ -1,6 +1,10 @@
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title" style="font-size: 1.5rem;"><strong><%= dotation.name %></strong></h3>
<h3 class="card-title" style="font-size: 1.5rem;">
<strong>
<%= link_to dotation.name, "/dotacja/#{dotation.safe_id}" %>
</strong>
</h3>
<div class="card-tools">
</div>
</div>

View File

@ -0,0 +1,4 @@
<div class="alert alert-success">
<h5><i class="icon fas fa-info"></i> Informacja</h5>
Dziękujemy za zgłoszenie, wiadomość została przyjęta. Odpowiemy najszybciej jak to będzie możliwe.
</div>

View File

@ -114,12 +114,6 @@
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<%= raw @dotation.positioning_text %>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<h3>Pomoc w opracowaniu wniosku komu można zlecić opracowanie dokumentów do tego konkursu</h3>
@ -130,6 +124,23 @@
<%= render '/partners/partner_show', partner: @dotation.partner %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= raw @dotation.positioning_text %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<% @dotation.tags.each do |tag| %>

View File

@ -111,12 +111,6 @@
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<%= raw dotation.positioning_text %>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<h3>Pomoc w opracowaniu wniosku komu można zlecić opracowanie dokumentów do tego konkursu</h3>

View File

@ -19,24 +19,41 @@
<div class="col-md-8">
<div class="card">
<div class="card-header">
<h3 class="card-title">Kontakt</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
<i class="fas fa-minus"></i>
</button>
<button type="button" class="btn btn-tool" data-card-widget="remove" title="Remove">
<i class="fas fa-times"></i>
</button>
</div>
<h3 class="card-title">Dane kontaktowe</h3>
</div>
<div class="card-body">
Kontakt
</div>
<div class="row">
<div class="col-md-7" id="map_grantera">
<div class="card-footer">
Footer
</div>
<div class="col-md-1"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBB6-CyLLXNir-Mg6zYy6gcm-tzRB1Y198&callback=initMap&v=weekly&channel=2" async></script>
<div class="col-md-4">
<h2>Grantera sp. z o.o.</h2>
<p>
ul. Mikołaja Gomółki 2<br />
80-279 Gdańsk<br />
</p>
<br />
<p>
tel. 58 380 15 96<br />
tel. kom. 792 002 220<br />
info@grantera.pl<br />
</p>
<br />
<p>
KRS 0000529767,<br />
NIP 585-14-69-751<br />
</p>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<h3 class="card-title">Formularz kontaktowy</h3>
</div>
<%= render 'contact_form', email_message: @email_message %>
</div>
</div>
@ -44,3 +61,30 @@
</div>
</div>
</section>
<style>
/* Set the size of the div element that contains the map */
#map_grantera {
height: 400px;
/* The height is 400 pixels */
width: 100%;
/* The width is the width of the web page */
}
</style>
<script type="text/javascript">
// Initialize and add the map
function initMap() {
// The location of Uluru
const grantera = { lat: 54.385723142691006, lng: 18.579579069489338 };
// The map, centered at Uluru
const map = new google.maps.Map(document.getElementById("map_grantera"), {
zoom: 16,
center: grantera,
});
// The marker, positioned at Uluru
const marker = new google.maps.Marker({
position: grantera,
map: map,
});
}
initMap();
</script>

View File

@ -1,20 +1,6 @@
<section class="content">
<div class="container-fluid">
<h2 class="text-center display-4">Kalendarz Dotacji</h2>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<br />
<br />
<br />
<p>Tutaj jakieś informacje co znajduje się na tej stronie czego można się spodziewać itd, może jakieś zdjęcie? coś do przemyślenia</p>
<br />
<br />
<br />
</div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="row" style="padding-top:30px;">
<div class="col-md-8 offset-md-2">
<div class="input-group">
<%= text_field_tag(:search, params[:search], class: 'form-control form-control-lg', placeholder: 'Wpisz wyszukiwaną frazę', id: 'search_input') %>

View File

@ -0,0 +1,6 @@
<% if @email_message.errors.any? %>
$("#email_mess_div").html("<%= escape_javascript(render '/shared/errors_list', error_object: @email_message) %>");
<% else %>
document.getElementById("contact_form_form").reset();
$("#email_mess_div").html("<%= escape_javascript(render '/home/message_sent_info') %>");
<% end %>

View File

@ -8,7 +8,7 @@
<%= csp_meta_tag %>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'font_awesomeall', 'tempusdominus-bootstrap-4.min', 'select2.min', 'adminlte.min' %>
<%= stylesheet_link_tag 'font_awesomeall', 'tempusdominus-bootstrap-4.min', 'select2.min', 'adminlte.min', 'main' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
@ -17,8 +17,7 @@
<nav class="main-header navbar navbar-expand-md navbar-light navbar-white">
<div class="container">
<a href="/" class="navbar-brand">
<%= image_tag "logo_kd.png", class: "brand-image img-circle elevation-3", alt: "AdminLTE Logo", style: "opacity: .8" %>
<span class="brand-text font-weight-light">Kalendarz Dotacji</span>
<%= image_tag "kd_logo.png", class: "brand-image elevation-3", alt: "Kalendarz dotacji", style: "opacity: .8" %>
</a>
<button class="navbar-toggler order-1" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -36,11 +35,14 @@
</div>
</div>
</nav>
</div>
<header class="mainer-header">
</header>
<div class="content-wrapper">
<%= yield %>
</div>
</div>
<%= javascript_include_tag 'jquery.min', 'bootstrap.bundle.min', 'bs-custom-file-input.min', 'moment-with-locales.min', 'select2.full.min', 'tempusdominus-bootstrap-4.min', 'adminlte.min', 'bootstrap-switch.min', 'form_calendar' %>
<script type="text/javascript">
<%= yield :scripts %>

View File

@ -0,0 +1,21 @@
<table style="font-family:Verdana,sans-serif; font-size:18px; color:#374953;">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td align="left">
Witaj, <br />
Pojawiła się nowa wiadomość ze strony.<br />
Nadawca wiadomości: <strong><%= @email_message.email %></strong><br />
Temat: <strong><%= @email_message.subject %></strong><br />
Treść wiadomości: <br />
<%= @email_message.message %>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,6 @@
Witaj,
Pojawiła się nowa wiadomość ze strony.
Nadawca wiadomości: <%= @email_message.email %>
Temat: <%= @email_message.subject %>
Treść wiadomości:
<%= @email_message.message %>

View File

@ -6,7 +6,11 @@
</div>
<div class="form-group">
<%= form.label :description %>
<%= form.text_field :description, class: 'form-control', placeholder: 'Wprowadź opis' %>
<%= form.text_area :description, class: 'form-control', placeholder: 'Wprowadź opis' %>
</div>
<div class="form-group">
<%= form.label :link_url %>
<%= form.text_field :link_url, class: 'form-control', placeholder: 'Wprowadź e-mail do powiadomień' %>
</div>
<div class="form-group">
<div class="custom-file">

View File

@ -9,11 +9,6 @@
<% end %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<strong><%= partner.name %></strong>
</div>
</div>
</td>
<td><%= raw partner.description %></td>
<td><button type="button" class="btn btn-block btn-success">Zamów bezpłatną konsultację</button></td>

View File

@ -11,11 +11,6 @@
<% end %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<strong><%= partner.name %></strong>
</div>
</div>
</td>
<td><%= raw partner.description %></td>
</tr>

View File

@ -1 +1,2 @@
mail_link: 'http://localhost:3434'
notify_email: 'adhinz@gmail.com'

View File

@ -31,7 +31,7 @@ pl:
end_date: Data końca naboru
announcement_date: Data ogłoszenia naboru
tags: Tagi
full_descr: Pełen opis dotacji
full_descr: Pełny opis dotacji
positioning_text: Tekst pozycjonujący
errors:
models:

View File

@ -0,0 +1,21 @@
pl:
email_message:
message_sent: 'Dziękujemy za zgłoszenie, wiadomość została przyjęta. Odpowiemy najszybciej jak to będzie możliwe.'
activerecord:
models:
email_message: Wiadomość email
attributes:
email_message:
subject: "Temat"
email: "Adres e-mail"
message: Wiadomość
errors:
models:
email_message:
attributes:
subject:
blank: nie może być pusty
email:
blank: nie może być pusty
message:
blank: nie może być pusta

View File

@ -5,6 +5,7 @@ pl:
attributes:
partner:
name: "Nazwa"
link_url: "E-mail"
description: "Opis"
logo: Logo
errors:

View File

@ -7,6 +7,7 @@ Rails.application.routes.draw do
get 'home/search'
post 'home/search'
post 'home/emailfilter'
post 'home/register_contact'
resources :home, only: %i[index show]
devise_for :users
resources :company_sizes

View File

@ -0,0 +1,11 @@
class CreateEmailMessages < ActiveRecord::Migration[5.2]
def change
create_table :email_messages do |t|
t.string :subject
t.string :email
t.text :message
t.timestamps
end
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_03_28_092314) do
ActiveRecord::Schema.define(version: 2022_03_30_152005) do
create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "name", null: false
@ -134,6 +134,14 @@ ActiveRecord::Schema.define(version: 2022_03_28_092314) do
t.index ["dotation_id", "tag_id"], name: "dot_tag_ind"
end
create_table "email_messages", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "subject"
t.string "email"
t.text "message"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "expenses", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "name"
t.string "description"

View File

@ -58,10 +58,9 @@
<!-- This file lives in public/404.html -->
<div class="dialog">
<div>
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
<h1>Strona której szukasz nie istnieje.</h1>
<p>Możliwe, że adres został wpisany niepoprawnie lub strona została przeniesiona.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

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

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
subject: MyString
email: MyString
message: MyText
two:
subject: MyString
email: MyString
message: MyText

View File

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