diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8b5cb14..9c1efd5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,8 +2,20 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :authenticate_user! before_action :set_locale + layout :layout_by_resource def set_locale I18n.locale = params[:lang] || I18n.default_locale end + + protected + + def layout_by_resource + if devise_controller? && resource_name == :user && action_name == "new" + "devise" + else + "application" + end + end + end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index f9b859b..309b704 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -1,4 +1,5 @@ class WelcomeController < ApplicationController def index end + end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0b85755..0609e40 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,6 @@ module ApplicationHelper - + # define left menu def menu ret = "" ret += create_menu_li("glyphicon glyphicon-home","Dashboard","/","welcome") @@ -11,7 +11,7 @@ module ApplicationHelper return raw(ret) end - + # create left menu
  • element def create_menu_li(icon, name, link, controller_nmn) if controller_name == controller_nmn active = " class=\"current\"" @@ -22,8 +22,8 @@ module ApplicationHelper "#{icn}#{name}
  • " end - - def errors_to_html(errors) + # generate errors html + def errors_to_html(errors ) ret = '
    ' ret += I18n.t("activerecord.errors.messages.record_invalid", errors: errors.count) ret += '
      ' @@ -34,6 +34,7 @@ module ApplicationHelper ret end + # Change decimals to words in PLN def decimal_to_word(dec) singles = ["", " #{I18n.t('numbers.one')}", " #{I18n.t('numbers.two')}", " #{I18n.t('numbers.three')}", " #{I18n.t('numbers.four')}", " #{I18n.t('numbers.five')}", " #{I18n.t('numbers.six')}", " #{I18n.t('numbers.seven')}", " #{I18n.t('numbers.eight')}", " #{I18n.t('numbers.nine')}"] diff --git a/app/helpers/devise_helper.rb b/app/helpers/devise_helper.rb new file mode 100644 index 0000000..95a7630 --- /dev/null +++ b/app/helpers/devise_helper.rb @@ -0,0 +1,32 @@ +module DeviseHelper + def devise_error_messages! + return "" unless devise_error_messages? + + messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join + sentence = I18n.t("errors.messages.not_saved", + :count => resource.errors.count, + :resource => resource.class.model_name.human) + + html = <<-HTML +
      +
      +
      +
      + #{sentence} +
      +
      +
      +
        #{messages}
      +
      +
      +
      + HTML + + html.html_safe + end + + def devise_error_messages? + !resource.errors.empty? + end + +end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 1e66f3d..c52d568 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,43 +1,71 @@ -

      Edit <%= resource_name.to_s.humanize %>

      +
      +
      +
      +
      Profil - zmiana hasła
      +
      + <%= link_to raw(" " + I18n.t('back')), :back, title: I18n.t('back'), class: "text-primary" %> +
      +
      +
      +
      + <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: "form-horizontal" }) do |f| %> + <%= devise_error_messages! %> +
      + <%= f.label :email, class: "col-sm-2 control-label" %> +
      + <%= f.text_field :email, class: "form-control", placeholder: 'Email', autofocus: true %> +
      +
      + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +
      Currently waiting confirmation for: <%= resource.unconfirmed_email %>
      + <% end %> +
      + <%= f.label :password, class: "col-sm-2 control-label" %> +
      + <%= f.password_field :password, autocomplete: "off", class: "form-control", placeholder: 'Nowe Hasło' %> +

      + <% if @minimum_password_length %> + Minimialna ilość znakow: <%= @minimum_password_length %> + <% end %> + (Pozostaw puste jeśli nie chcesz zmieniać) +

      +
      +
      +
      + <%= f.label :password_confirmation, class: "col-sm-2 control-label" %> +
      + <%= f.password_field :password_confirmation, autocomplete: "off", class: "form-control", placeholder: 'Powtorz Hasło' %> + +
      +
      +
      + <%= f.label :current_password, class: "col-sm-2 control-label" %> +
      + <%= f.password_field :current_password, autocomplete: "off", class: "form-control", placeholder: 'Aktualne Hasło' %> +

      (Aktualne hasło jest potrzebne aby zatwierdzić zmiany)

      +
      +
      +
      +
      + <%= f.submit 'Zapisz', class: "btn btn-primary" %> +
      +
      + <% end %> +
      -<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> - <%= devise_error_messages! %> -
      - <%= f.label :email %>
      - <%= f.email_field :email, autofocus: true %>
      - - <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> -
      Currently waiting confirmation for: <%= resource.unconfirmed_email %>
      - <% end %> - -
      - <%= f.label :password %> (leave blank if you don't want to change it)
      - <%= f.password_field :password, autocomplete: "off" %> - <% if @minimum_password_length %> -
      - <%= @minimum_password_length %> characters minimum - <% end %>
      +
      +
      +
      +
      +
      Profil - usunięcie konta
      +
      +
      +

      Aplikacja Ci się znudziła?

      + <%= button_to "Anuluj konto", registration_path(resource_name), data: { confirm: "Czy na pewno chcesz anulować konto?" }, method: :delete, class: "btn btn-danger" %> +
      -
      - <%= f.label :password_confirmation %>
      - <%= f.password_field :password_confirmation, autocomplete: "off" %>
      - -
      - <%= f.label :current_password %> (we need your current password to confirm your changes)
      - <%= f.password_field :current_password, autocomplete: "off" %> -
      - -
      - <%= f.submit "Update" %> -
      -<% end %> - -

      Cancel my account

      - -

      Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

      - -<%= link_to "Back", :back %> +
      diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 5a238ce..534ec56 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,29 +1,26 @@ -

      Sign up

      - <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= devise_error_messages! %> - -
      - <%= f.label :email %>
      - <%= f.email_field :email, autofocus: true %> -
      - -
      - <%= f.label :password %> - <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum) - <% end %>
      - <%= f.password_field :password, autocomplete: "off" %> -
      - -
      - <%= f.label :password_confirmation %>
      - <%= f.password_field :password_confirmation, autocomplete: "off" %> -
      - -
      - <%= f.submit "Sign up" %> +
      +
      <% end %> - -<%= render "devise/shared/links" %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 4960c33..98a48f7 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -12,6 +12,10 @@
      +
      +

      Nie posiadasz jeszcze konta?

      + <%= link_to t("sign_up"), new_registration_path(resource_name) %> +
    <% end %> diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index e6a3e41..f881699 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -1,21 +1,21 @@ <%- if controller_name != 'sessions' %> - <%= link_to "Log in", new_session_path(resource_name) %>
    + <%= link_to t("log_in"), new_session_path(resource_name) %>
    <% end -%> <%- if devise_mapping.registerable? && controller_name != 'registrations' %> - <%= link_to "Sign up", new_registration_path(resource_name) %>
    + <%= link_to t("sign_up"), new_registration_path(resource_name) %>
    <% end -%> <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> - <%= link_to "Forgot your password?", new_password_path(resource_name) %>
    + <%= link_to t("forgot_your_password"), new_password_path(resource_name) %>
    <% end -%> <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> - <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
    + <%= link_to t("didnt_receive_confirmation_instructions"), new_confirmation_path(resource_name) %>
    <% 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("didnt_receive_unlock_instructions"), new_unlock_path(resource_name) %>
    <% end -%> <%- if devise_mapping.omniauthable? %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6ebd467..31f04c0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ - FireStorm - Faktury + Invoice Keeper <%= csrf_meta_tags %> @@ -16,7 +16,7 @@
    @@ -28,12 +28,12 @@
    diff --git a/config/locales/devise.pl.yml b/config/locales/devise.pl.yml new file mode 100644 index 0000000..9a0a7be --- /dev/null +++ b/config/locales/devise.pl.yml @@ -0,0 +1,60 @@ +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n + +pl: + devise: + confirmations: + confirmed: "Twoje konto zostało aktywowane. Zostałeś pomyślnie zalogowany." + send_instructions: "Za chwilę otrzymasz email z instrukcją jak aktywować konto." + send_paranoid_instructions: "Jeśli Twój adres email istnieje w naszej bazie, za chwilę powinieneś otrzymać instrukcję jak aktywować konto." + failure: + already_authenticated: "Jesteś aktualnie zalogowany." + inactive: "Twoje konto nie zostało jeszcze aktywowane." + invalid: "Błędny adres email lub hasło." + invalid_token: "Błędny token aktywacyjny." + locked: "Twoje konto jest zablokowane." + not_found_in_database: "Błędny adres email lub hasło." + timeout: "Sesja wygasła, zaloguj się ponownie by kontynuować." + unauthenticated: "Aby kontynuować musisz się zalogować." + unconfirmed: "Aby kontynuować musisz aktywować swoje konto." + mailer: + confirmation_instructions: + subject: "Instrukcja aktywacji konta" + reset_password_instructions: + subject: "Instrukcja zresetowania hasła." + unlock_instructions: + subject: "Instrukcja odblokowania konta" + omniauth_callbacks: + failure: "Logowanie przez konto %{kind} zakończyło się błędem: \"%{reason}\"." + success: "Zalogowałeś się pomyślnie przez konto %{kind}." + passwords: + no_token: "Dostęp do tej strony jest możliwy jedynie poprzez użycie prawidłowego adresu z emaila z instrukcjami o resecie hasłą. Jeżeli właśnie skorzystałeś z tego adresu, sprawdź czy użyty adres jest zgodny z tym w emailu." + send_instructions: "Za chwilę otrzymasz emaila z instrukcją jak zresetować hasło." + send_paranoid_instructions: "Jeżeli Twój adres istnieje w naszej bazie, otrzymasz za chwilę emaila z instrukcją zmiany hasła." + updated: "Twoje hasło zostało zmienione. Zostałeś pomyślnie zalogowany." + updated_not_active: "Twoje hasło zostało zmienione." + registrations: + destroyed: "Do widzenia! Twoje konto zostało usunięte." + signed_up: "Witaj! Zarejestrowałeś się pomyślnie." + signed_up_but_inactive: "Zarejestrowałeś się pomyślnie. Niemniej jednak nie zostałeś zalogowany, ponieważ Twoje konto nie zostało jeszcze aktywowane." + signed_up_but_locked: "Zarejestrowałeś się pomyślnie. Niemniej jednak nie zostałeś zalogowany, ponieważ Twoje konto zostało zablokowane." + signed_up_but_unconfirmed: "Wiadomość email z instrukcją aktywacji konta została przesłana na Twój adres email. Użj linku z emaila aby aktywować konto." + update_needs_confirmation: "Konto zostało zaktualizowane. Niemniej jednak przed wprowadzeniem zmian musimy potwierdzić Twój nowy adres email. Za chwilę wyślemy instrukcję na nowy adres." + updated: "Konto zostało pomyślnie zaktualizowane." + sessions: + user: + signed_in: "Zostałeś zalogowany." + signed_out: "Zostałeś wylogowany." + unlocks: + send_instructions: "Za chwilę otrzymasz wiadomość email z instrukcją jak odblokować konto." + send_paranoid_instructions: "Jeżeli Twoje konto istnieje, otrzymasz wiadomość emial z instrukcją jak odblokować konto." + unlocked: "Twoje konto została pomyślnie odblokowane. Zaloguj się by kontynuować." + errors: + messages: + already_confirmed: "już został aktywowany, proszę spróbować się zalogować." + confirmation_period_expired: "musi zostać potwierdzony w czasie %{period}, wyślij zapytanie o nowy." + expired: "stracił ważność, wyślij zapytanie o nowy." + not_found: "nie znaleziono" + not_locked: "nie był zablokowany" + not_saved: + one: "%{resource} nie został zapisany z powodu błędu:" + other: "%{resource} nie został zapisany z powodu następujących błędów:" diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 91422f0..f782c1d 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -1,12 +1,20 @@ pl: back: 'Powrót' save: 'Zapisz' + log_in: 'Zaloguj' + log_out: 'Wyloguj' + sign_up: 'Zarejestruj' + forgot_your_password: 'Zapmniałeś hasła?' + didnt_receive_confirmation_instructions: 'Nie otrzymałeś instrukcji potwierdzenia?' + didnt_receive_unlock_instructions: 'Nie otrzymałeś instrukcji odblokowania?' menu: dashboard: 'Dashboard' customers: 'Klienci' products: 'Produkty' invoices: 'Faktury' activerecord: + models: + user: 'Użytkownik' attributes: customer: name: 'Nazwa firmy' @@ -15,6 +23,10 @@ pl: postcode: 'Kod pocztowy' nip: 'NIP' regon: 'Regon' + user: + password: 'Hasło' + current_password: 'Aktualne hasło' + password_confirmation: 'Potwierdzenie hasła' errors: messages: record_invalid: 'Negatywne sprawdzenie poprawności: %{errors}' diff --git a/config/routes.rb b/config/routes.rb index 4e2991c..9c39fc8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,6 @@ Rails.application.routes.draw do resources :invoices resources :customers - root 'welcome#index' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end