From 4d13d81967e405a2f5a6e4edd6fdc777e9ad2c4f Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Wed, 8 May 2019 17:55:37 +0200 Subject: [PATCH] Added devise login view --- app/assets/javascripts/tests.js | 2 + app/assets/stylesheets/tests.css | 4 + app/controllers/application_controller.rb | 11 ++ app/controllers/tests_controller.rb | 9 ++ app/helpers/tests_helper.rb | 2 + app/views/devise/sessions/new.html.erb | 49 ++++--- app/views/devise/shared/_links.html.erb | 24 +++- app/views/layouts/devise.html.erb | 30 +++++ app/views/tests/index.html.erb | 2 + app/views/tests/test.html.erb | 2 + config/application.rb | 6 + config/environments/development.rb | 4 +- config/locales/devise.pl.yml | 151 ++++++++++++++++++++++ config/locales/pl/pl.yml | 33 +++++ config/routes.rb | 2 + spec/controllers/tests_controller_spec.rb | 19 +++ spec/helpers/tests_helper_spec.rb | 15 +++ spec/views/tests/index.html.erb_spec.rb | 5 + spec/views/tests/test.html.erb_spec.rb | 5 + 19 files changed, 346 insertions(+), 29 deletions(-) create mode 100644 app/assets/javascripts/tests.js create mode 100644 app/assets/stylesheets/tests.css create mode 100644 app/controllers/tests_controller.rb create mode 100644 app/helpers/tests_helper.rb create mode 100644 app/views/layouts/devise.html.erb create mode 100644 app/views/tests/index.html.erb create mode 100644 app/views/tests/test.html.erb create mode 100644 config/locales/devise.pl.yml create mode 100644 config/locales/pl/pl.yml create mode 100644 spec/controllers/tests_controller_spec.rb create mode 100644 spec/helpers/tests_helper_spec.rb create mode 100644 spec/views/tests/index.html.erb_spec.rb create mode 100644 spec/views/tests/test.html.erb_spec.rb diff --git a/app/assets/javascripts/tests.js b/app/assets/javascripts/tests.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/tests.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/tests.css b/app/assets/stylesheets/tests.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/tests.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d1..7d556f8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,13 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::Base + # before_action :authenticate_user! + + layout :layout_by_resource + + private + + def layout_by_resource + devise_controller? ? 'devise' : 'application' + end end diff --git a/app/controllers/tests_controller.rb b/app/controllers/tests_controller.rb new file mode 100644 index 0000000..f47b6cf --- /dev/null +++ b/app/controllers/tests_controller.rb @@ -0,0 +1,9 @@ +class TestsController < ApplicationController + def index + end + + def test + # u = User.create(email: 'ahinz@o2.pl', password: 'qazxsw123') + u = User.create(email: 'adhinz@gmail.com', password: 'qazxsw123') + end +end diff --git a/app/helpers/tests_helper.rb b/app/helpers/tests_helper.rb new file mode 100644 index 0000000..c54aa99 --- /dev/null +++ b/app/helpers/tests_helper.rb @@ -0,0 +1,2 @@ +module TestsHelper +end diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 5ede964..3bab851 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,26 +1,33 @@ -

Log in

+ +
+ +
+
+
+

Witaj!

+
-<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> -
+ <%= form_for(resource, as: resource_name, url: session_path(resource_name), html: {class: 'user'}) do |f| %> +
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: 'Email', class: 'form-control form-control-user' %> +
-
- <%= f.label :password %>
- <%= f.password_field :password, autocomplete: "current-password" %> -
+
+ <%= f.password_field :password, autocomplete: "current-password", placeholder: 'Hasło', class: 'form-control form-control-user' %> +
- <% if devise_mapping.rememberable? %> -
- <%= f.check_box :remember_me %> - <%= f.label :remember_me %> + <% if devise_mapping.rememberable? %> +
+
+ <%= f.check_box :remember_me, class: 'custom-control-input' %> + <%= f.label :remember_me, class: 'custom-control-label' %> +
+
+ <% end %> + <%= f.submit t('login'), class: 'btn btn-primary btn-user btn-block' %> + <% end %> +
+ <%= render "devise/shared/links" %>
- <% end %> - -
- <%= f.submit "Log in" %>
-<% end %> - -<%= render "devise/shared/links" %> +
diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index 084af70..17753e4 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -1,25 +1,37 @@ <%- if controller_name != 'sessions' %> - <%= link_to "Log in", new_session_path(resource_name) %>
+
+ <%= link_to t('devise.shared.links.sign_in'), new_session_path(resource_name), class: 'small' %> +
<% end %> <%- if devise_mapping.registerable? && controller_name != 'registrations' %> - <%= link_to "Sign up", new_registration_path(resource_name) %>
+
+ <%= link_to t('devise.shared.links.sign_up'), new_registration_path(resource_name), class: 'small' %> +
<% end %> <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> - <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+
+ <%= link_to t('devise.shared.links.forgot_your_password'), new_password_path(resource_name), class: 'small' %> +
<% end %> <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> - <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+
+ <%= link_to t('devise.shared.links.didn_t_receive_confirmation_instructions'), new_confirmation_path(resource_name), class: 'small' %> +
<% end %> <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> - <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+
+ <%= link_to t('devise.shared.links.didn_t_receive_unlock_instructions'), new_unlock_path(resource_name), class: 'small' %> +
<% end %> <%- if devise_mapping.omniauthable? %> <%- resource_class.omniauth_providers.each do |provider| %> - <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %>
+
+ <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), class: 'small' %> +
<% end %> <% end %> diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb new file mode 100644 index 0000000..4cb9b9b --- /dev/null +++ b/app/views/layouts/devise.html.erb @@ -0,0 +1,30 @@ + + + + Kurs + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + <%= favicon_link_tag %> + + + <%= stylesheet_link_tag 'application', media: 'all' %> + + <%= javascript_include_tag 'application' %> + + +
+ +
+
+
+
+ <%= yield %> +
+
+
+
+
+ <%= javascript_include_tag 'jquery.min', 'bootstrap.bundle.min' %> + <%= javascript_include_tag 'jquery.easing.min', 'sb-admin-2.min' %> + + diff --git a/app/views/tests/index.html.erb b/app/views/tests/index.html.erb new file mode 100644 index 0000000..5a4c8ac --- /dev/null +++ b/app/views/tests/index.html.erb @@ -0,0 +1,2 @@ +

Tests#index

+

Find me in app/views/tests/index.html.erb

diff --git a/app/views/tests/test.html.erb b/app/views/tests/test.html.erb new file mode 100644 index 0000000..009466b --- /dev/null +++ b/app/views/tests/test.html.erb @@ -0,0 +1,2 @@ +

Tests#test

+

Find me in app/views/tests/test.html.erb

diff --git a/config/application.rb b/config/application.rb index 011c189..efc18bd 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,13 @@ Bundler.require(*Rails.groups) module CoursePlatform class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. + config.time_zone = 'Warsaw' + config.active_record.default_timezone = :local config.load_defaults 5.2 + config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', + '*.{rb,yml}').to_s] + config.i18n.default_locale = :pl + config.encoding = 'utf-8' config.generators.javascript_engine = :js # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/environments/development.rb b/config/environments/development.rb index 5ebfb91..03de161 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -36,8 +36,8 @@ Rails.application.configure do config.action_mailer.smtp_settings = { address: 'smtp.gmail.com', port: 587, - domain: 'akademiatechnologii.pl', - user_name: 'akademiatechnologii@gmail.com', + domain: 'akadeniatechnologii.pl', + user_name: 'akadeniatechnologii@gmail.com', password: '12345%$#@!Adi', authentication: 'plain', enable_starttls_auto: true diff --git a/config/locales/devise.pl.yml b/config/locales/devise.pl.yml new file mode 100644 index 0000000..c88b65b --- /dev/null +++ b/config/locales/devise.pl.yml @@ -0,0 +1,151 @@ +pl: + activerecord: + attributes: + user: + confirmation_sent_at: Data wysłania potwierdzenia + confirmation_token: Token potwierdzający + confirmed_at: Data potwierdzenia + created_at: Data utworzenia + current_password: Aktualne hasło + current_sign_in_at: Data bieżącego logowania + current_sign_in_ip: Bieżący adres IP + email: Adres e-mail + encrypted_password: Zaszyfrowane hasło + failed_attempts: Nieudanych prób + last_sign_in_at: Data ostatniego logowania + last_sign_in_ip: Ostatni adres IP + locked_at: Data zablokowania + password: Hasło + password_confirmation: Potwierdzenie hasła + remember_created_at: Data utworzenia zapamiętania logowania + remember_me: Zapamiętaj mnie + reset_password_sent_at: Data wysłania żądania resetu hasła + reset_password_token: Token umożliwiający reset hasła + sign_in_count: Liczba logowań + unconfirmed_email: Niepotwierdzony adres e-mail + unlock_token: Token odblokowywujący + updated_at: Data uaktualnienia + models: + user: + few: Użytkowników + one: Użytkownik + other: Użytkowników + devise: + confirmations: + confirmed: Twój adres e-mail został potwierdzony. + new: + resend_confirmation_instructions: Wyślij ponownie instrukcje aktywacji + send_instructions: Instrukcja jak aktywować konto zostanie niezwłocznie wysłana na podany adres e-mail. + send_paranoid_instructions: Jeśli Twój adres e-mail istnieje w naszej bazie, w ciągu najbliższych minut otrzymasz instrukcje jak aktywować konto. + failure: + already_authenticated: Jesteś już zalogowany. + inactive: Twoje konto nie zostało jeszcze aktywowane. + invalid: Błędny adres %{authentication_keys} lub hasło. + last_attempt: Masz jeszcze jedną próbę nim Twoje konto zostanie zablokowane. + locked: Twoje konto jest zablokowane. + not_found_in_database: Błędny adres %{authentication_keys} lub hasło. + timeout: Sesja wygasła, aby kontynuować zaloguj się ponownie. + unauthenticated: Aby kontynuować zaloguj lub zarejestruj się. + unconfirmed: Aby kontynuować aktywuj konto. + mailer: + confirmation_instructions: + action: Potwierdź swoje konto + greeting: Witaj %{recipient}! + instruction: 'Możesz potwierdzić swoje konto przy pomocy poniższego linku:' + subject: Instrukcja aktywacji konta + email_changed: + greeting: Witaj %{recipient}! + message: Kontaktujemy się z Tobą, aby Cię poinformować o zmianie Twojego adresu e-mail na %{email}. + subject: E-mail zmieniony + password_change: + greeting: Witaj %{recipient}! + message: Kontaktujemy się z Tobą w celu poinformowania, że Twoje hasło zostało zmienione. + subject: Hasło zostało zmienione + reset_password_instructions: + action: Zmień swoje hasło + greeting: Cześć %{recipient}! + instruction: Ktoś zażądał zmiany hasła do Twojego konta. Hasło możesz zmienić wchodząc na poniższy link. + instruction_2: Jeśli to nie Ty zażądałeś zmiany hasła, proszę zignoruj tę wiadomość. + instruction_3: Twoje hasło nie ulegnie zmianie dopóki nie wejdziesz na poniższy link i nie ustawisz nowego. + subject: Instrukcja ustawienia nowego hasła + unlock_instructions: + action: Odblokuj swoje konto + greeting: Cześć %{recipient}! + instruction: 'Kliknij poniższy link, aby odblokować swoje konto:' + message: Twoje konto zostało zablokowane z powodu zbyt dużej liczby nieprawidłowych prób zalogowania się na nie. + subject: Instrukcja odblokowania konta + omniauth_callbacks: + failure: Logowanie przez konto %{kind} zakończyło się błędem z powodu "%{reason}". + success: Logowanie przez konto %{kind} zakończyło się pomyślnie. + passwords: + edit: + change_my_password: Zmień moje hasło + change_your_password: Zmień swoje hasło + confirm_new_password: Powtórz nowe hasło + new_password: Nowe hasło + new: + forgot_your_password: Zapomniałeś swojego hasła? + send_me_reset_password_instructions: Wyślij instrukcje zmiany hasła + no_token: Do tej strony możesz dostać się tylko poprzez wiadomość e-mail resetującą hasło. Jeśli to z niej tu trafiłeś, upewnij się, że użyłeś pełnego adresu. + send_instructions: Instrukcja zmiany hasła zostanie niezwłocznie wysłana na podany adres e-mail. + send_paranoid_instructions: Jeśli Twój adres e-mail istnieje w naszej bazie, otrzymasz zaraz wiadomość z instrukcjami odzyskiwania hasła. + updated: Hasło zmienione poprawnie. Zostałeś automatycznie zalogowany. + updated_not_active: Twoje hasło zmienione poprawnie. + registrations: + destroyed: Twoje konto zostało usunięte. + edit: + are_you_sure: Jesteś pewny? + cancel_my_account: Anuluj moje konto + currently_waiting_confirmation_for_email: 'Aktualnie oczekujemy na potwierdzenie z: %{email}' + leave_blank_if_you_don_t_want_to_change_it: pozostaw puste, jeśli nie chcesz wprowadzać zmian + title: Edytuj %{resource} + unhappy: Niezadowolony + update: Aktualizuj + we_need_your_current_password_to_confirm_your_changes: potrzebujemy Twojego bieżącego hasła, aby potwierdzić zmiany + new: + sign_up: Zarejestruj się + signed_up: Witaj! Rejestracja zakończyła się pomyślnie. + signed_up_but_inactive: Konto zostało utworzone pomyślnie. Zanim się jednak zalogujesz, musi ono zostać jeszcze aktywowane. + signed_up_but_locked: Konto zostało utworzone pomyślnie. Nie możesz się jednak zalogować, ponieważ jest ono zablokowane. + signed_up_but_unconfirmed: Wiadomość z linkiem aktywacyjnym została wysłana na podany adres e-mail. Otwórz link w celu aktywacji konta. + update_needs_confirmation: Konto zostało zaktualizowane, musimy jednak potwierdzić nowy adres e-mail. Sprawdź swoją skrzynkę pocztową i otwórz link aktywacyjny, aby ukończyć zmianę adresu. + updated: Konto zostało pomyślnie zaktualizowane. + updated_but_not_signed_in: + sessions: + already_signed_out: Wylogowano pomyślnie. + new: + sign_in: Zaloguj się + signed_in: Zalogowano pomyślnie. + signed_out: Wylogowano pomyślnie. + shared: + links: + back: Powrót + didn_t_receive_confirmation_instructions: Nie otrzymałeś instrukcji aktywacji konta? + didn_t_receive_unlock_instructions: Nie otrzymałeś instrukcji odblokowania konta? + forgot_your_password: Zapomniałeś hasła? + sign_in: Zaloguj się + sign_in_with_provider: Zaloguj się przez %{provider} + sign_up: Zarejestruj się + minimum_password_length: + few: "(minimum %{count} znaki)" + many: "(minimum %{count} znaków)" + one: "(minimum %{count} znak)" + other: "(minimum %{count} znaku)" + unlocks: + new: + resend_unlock_instructions: Wyślij instrukcje odblokowania konta + send_instructions: Wkrótce powinieneś otrzymać e-mail z instrukcjami jak odblokować swoje konto. + send_paranoid_instructions: Jeśli Twoje konto istnieje w naszej bazie, otrzymasz zaraz e-mail z instrukcjami jak odblokować swoje konto. + unlocked: Twoje konto zostało odblokowane. Zaloguj się, aby kontynuować. + errors: + messages: + already_confirmed: już został aktywowany, możesz się zalogować + confirmation_period_expired: musi być potwierdzone w ciągu %{period}, zamów nową wiadomość aktywacyjną + expired: stracił ważność, wyślij zapytanie o nowy + not_found: nie znaleziono + not_locked: nie był zablokowany + not_saved: + few: "%{resource} nie został zapisany z powodu %{count} błędów:" + many: "%{resource} nie został zapisany z powodu %{count} błędów:" + one: "%{resource} nie został zapisany z powodu jednego błędu:" + other: "%{resource} nie został zapisany z powodu %{count} błędów:" \ No newline at end of file diff --git a/config/locales/pl/pl.yml b/config/locales/pl/pl.yml new file mode 100644 index 0000000..4472a37 --- /dev/null +++ b/config/locales/pl/pl.yml @@ -0,0 +1,33 @@ +pl: + logout: 'Wyloguj' + login: 'Zaloguj' + add: 'Dodaj' + actions: 'Akcje' + information: 'Informacja' + empty_list: 'Nie znaleziono żadnych elementów do wyświetlenia.' + edit: 'Edycja' + delete: 'Kasowanie' + confirm_delete: 'Czy na pewno usunąć ten element?' + phone: 'Telefon' + mobile: 'Komórkowy' + landline: 'Stacjonarny' + client: 'Klient' + email: 'Email' + city: 'Miasto' + street: 'Ulica' + nip: 'NIP' + regon: 'Regon' + www: 'Strona WWW' + full_address: 'Pełen adres' + add_cancel: 'Anuluj dodawanie' + please_wait: 'Proszę czekać...' + errors_ocurred: 'Wystąpiły następujące błędy:' + save: 'Zapisz' + login_form: + login_top: 'Zaloguj się' + login: 'Zaloguj' + email: 'Adres e-mail' + password: 'Hasło' + forgot_password: 'Zapomniane hasło?' + no_account: 'Nie masz konta?' + spikon_inv: 'Zapraszamy do Spikon!' diff --git a/config/routes.rb b/config/routes.rb index 0ada381..3c41a74 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Rails.application.routes.draw do + get 'tests/index' + get 'tests/test' namespace :admin do resources :users end diff --git a/spec/controllers/tests_controller_spec.rb b/spec/controllers/tests_controller_spec.rb new file mode 100644 index 0000000..d51c324 --- /dev/null +++ b/spec/controllers/tests_controller_spec.rb @@ -0,0 +1,19 @@ +require 'rails_helper' + +RSpec.describe TestsController, type: :controller do + + describe "GET #index" do + it "returns http success" do + get :index + expect(response).to have_http_status(:success) + end + end + + describe "GET #test" do + it "returns http success" do + get :test + expect(response).to have_http_status(:success) + end + end + +end diff --git a/spec/helpers/tests_helper_spec.rb b/spec/helpers/tests_helper_spec.rb new file mode 100644 index 0000000..0497896 --- /dev/null +++ b/spec/helpers/tests_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the TestsHelper. For example: +# +# describe TestsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe TestsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/tests/index.html.erb_spec.rb b/spec/views/tests/index.html.erb_spec.rb new file mode 100644 index 0000000..e5c6919 --- /dev/null +++ b/spec/views/tests/index.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "tests/index.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/tests/test.html.erb_spec.rb b/spec/views/tests/test.html.erb_spec.rb new file mode 100644 index 0000000..af648f8 --- /dev/null +++ b/spec/views/tests/test.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "tests/test.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end