Merge branch 'master' of ssh://51.254.143.84:9319/home/git/invoice_keeper

This commit is contained in:
Adrian Hinz 2016-10-11 07:31:53 +02:00
commit 2e6dc69b26
13 changed files with 226 additions and 80 deletions

View File

@ -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

View File

@ -1,4 +1,5 @@
class WelcomeController < ApplicationController
def index
end
end

View File

@ -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 <li> element
def create_menu_li(icon, name, link, controller_nmn)
if controller_name == controller_nmn
active = " class=\"current\""
@ -22,7 +22,7 @@ module ApplicationHelper
"<li#{active}><a href=\"#{link}\">#{icn}#{name}</a></li>"
end
# generate errors html
def errors_to_html(errors )
ret = '<div class="row"><div class="col-lg-12 col-md-12 panel-danger"><div class="content-box-header panel-heading"><div class="panel-title">'
ret += I18n.t("activerecord.errors.messages.record_invalid", errors: errors.count)
@ -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')}"]

View File

@ -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
<div class="row">
<div class="col-lg-12 col-md-12 panel-danger">
<div class="content-box-header panel-heading">
<div class="panel-title">
#{sentence}
</div>
</div>
<div class="content-box-large box-with-header" style="background:#f9dddd">
<ul>#{messages}</ul>
</div>
</div>
</div>
HTML
html.html_safe
end
def devise_error_messages?
!resource.errors.empty?
end
end

View File

@ -1,43 +1,71 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
<div class="row">
<div class="col-lg-8 col-md-12 panel-info">
<div class="content-box-header panel-heading">
<div class="panel-title">Profil - zmiana hasła</div>
<div class="panel-options">
<%= link_to raw("<i class=\"glyphicon glyphicon-arrow-left text-success\"></i> " + I18n.t('back')), :back, title: I18n.t('back'), class: "text-primary" %>
</div>
</div>
<div class="content-box-large box-with-header">
<div class="row">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: "form-horizontal" }) do |f| %>
<%= devise_error_messages! %>
<div class="form-group">
<%= f.label :email, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :email, class: "form-control", placeholder: 'Email', autofocus: true %>
</div>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %>
<div class="form-group">
<%= f.label :password, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.password_field :password, autocomplete: "off", class: "form-control", placeholder: 'Nowe Hasło' %>
<p class="note">
<% if @minimum_password_length %>
<br />
<em><%= @minimum_password_length %> characters minimum</em>
<strong><em>Minimialna ilość znakow: <%= @minimum_password_length %></em></strong>
<% end %>
<i>(Pozostaw puste jeśli nie chcesz zmieniać)</i>
</p>
</div>
</div>
<div class="form-group">
<%= f.label :password_confirmation, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.password_field :password_confirmation, autocomplete: "off", class: "form-control", placeholder: 'Powtorz Hasło' %>
</div>
</div>
<div class="form-group">
<%= f.label :current_password, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.password_field :current_password, autocomplete: "off", class: "form-control", placeholder: 'Aktualne Hasło' %>
<p class="note"><i>(Aktualne hasło jest potrzebne aby zatwierdzić zmiany)</i></p>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= f.submit 'Zapisz', class: "btn btn-primary" %>
</div>
</div>
<% end %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-12 panel-danger">
<div class="content-box-header panel-heading">
<div class="panel-title">Profil - usunięcie konta</div>
</div>
<div class="content-box-large box-with-header">
<h4>Aplikacja Ci się znudziła?</h4>
<%= button_to "Anuluj konto", registration_path(resource_name), data: { confirm: "Czy na pewno chcesz anulować konto?" }, method: :delete, class: "btn btn-danger" %>
</div>
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>

View File

@ -1,29 +1,26 @@
<h2>Sign up</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password %>
<div class="col-md-4 col-md-offset-4">
<div class="login-wrapper">
<div class="box">
<div class="content-wrap">
<h6>Zarejestruj</h6>
<%= f.email_field :email, autofocus: true, class: 'form-control', placeholder: 'E-mail' %>
<%= f.password_field :password, autocomplete: "off", class: 'form-control', placeholder: 'Hasło' %>
<p class="note">
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
<strong><em>Minimialna ilość znakow: <%= @minimum_password_length %></em></strong>
<% end %>
</p>
<%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control', placeholder: 'Powtorz Hasło' %>
<div class="action">
<%= f.submit "Zarejestruj", class: "btn btn-primary signup" %>
</div>
</div>
</div>
<div class="already">
<p>Posiadasz juz konto?</p>
<%= link_to t("log_in"), new_registration_path(resource_name) %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@ -12,6 +12,10 @@
</div>
</div>
</div>
<div class="already">
<p>Nie posiadasz jeszcze konta?</p>
<%= link_to t("sign_up"), new_registration_path(resource_name) %>
</div>
</div>
</div>
<% end %>

View File

@ -1,21 +1,21 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<%= link_to t("log_in"), new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<%= link_to t("sign_up"), new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<%= link_to t("forgot_your_password"), new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<%= link_to t("didnt_receive_confirmation_instructions"), new_confirmation_path(resource_name) %><br />
<% 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) %><br />
<%= link_to t("didnt_receive_unlock_instructions"), new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>FireStorm - Faktury</title>
<title>Invoice Keeper</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= csrf_meta_tags %>
@ -16,7 +16,7 @@
<div class="col-md-5">
<!-- Logo -->
<div class="logo">
<h1><a href="index.html">FireStorm - Faktury</a></h1>
<h1><a href="index.html">Invoice Keeper</a></h1>
</div>
</div>
<div class="col-md-5">
@ -28,12 +28,12 @@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Moje konto <b class="caret"></b></a>
<ul class="dropdown-menu animated fadeInUp">
<li><a href="profile.html">Profil</a></li>
<li><%= link_to "Profil", edit_user_registration_path %></li>
<li>
<% if user_signed_in? %>
<a href="login.html">Wyloguj</a>
<%= link_to('Wyloguj', destroy_user_session_path, :method => :delete) %>
<% else %>
<a href="login.html">Zaloguj</a>
<%= link_to('Zaloguj', new_user_session_path) %>
<% end %>
</li>
</ul>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>FireStorm - Faktury</title>
<title>Invoice Keeper</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= csrf_meta_tags %>
@ -15,7 +15,7 @@
<div class="col-md-12">
<!-- Logo -->
<div class="logo">
<h1><a href="index.html">FireStorm - Faktury</a></h1>
<h1><a href="index.html">Invoice Keeper</a></h1>
</div>
</div>
</div>

View File

@ -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:"

View File

@ -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}'

View File

@ -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