Compare commits

...

10 Commits

Author SHA1 Message Date
ahinz a4e9a56f68 ah 2015-09-29 14:23:18 +02:00
ahinz 3d9f7169be ` 2014-12-12 12:47:27 +01:00
ahinz 86a89a0164 ` 2014-12-12 12:36:21 +01:00
ahinz 436c6e2f1f ` 2014-12-12 12:34:47 +01:00
ahinz a98786f044 ` 2014-12-12 12:33:59 +01:00
ahinz b1f7a452a3 ` 2014-12-12 11:38:43 +01:00
ahinz eafdb61f2f ` 2014-12-12 10:55:27 +01:00
ahinz 2b7ad6b321 ` 2014-12-11 15:57:26 +01:00
ahinz 467545c85a ` 2014-12-11 15:56:40 +01:00
ahinz 3452a81971 ` 2014-12-11 15:45:49 +01:00
12 changed files with 200 additions and 31 deletions

View File

@ -2,4 +2,12 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception. # Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead. # For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception protect_from_forgery with: :exception
before_action :set_stuff
def set_stuff
# jezeli params[:locale] jest puste, zostanie uzyta wartosc I18n.default_locale
I18n.locale = params[:lang]
end
end end

View File

@ -1,6 +1,6 @@
class ArticlesController < ApplicationController class ArticlesController < ApplicationController
before_action :set_article, only: [:show, :edit, :update, :destroy] before_action :set_article, only: [:show, :edit, :update, :destroy]
before_filter :authenticate_user!, only: [:show, :edit, :update, :destroy] before_filter :authenticate_user!, only: [:new, :create, :edit, :update, :destroy]
# GET /articles # GET /articles
# GET /articles.json # GET /articles.json
@ -26,7 +26,8 @@ class ArticlesController < ApplicationController
# POST /articles.json # POST /articles.json
def create def create
@article = Article.new(article_params) @article = Article.new(article_params)
@article.created_by = current_user.id
@article.updated_by = current_user.id
respond_to do |format| respond_to do |format|
if @article.save if @article.save
format.html { redirect_to @article, notice: 'Article was successfully created.' } format.html { redirect_to @article, notice: 'Article was successfully created.' }

View File

@ -1,23 +1,19 @@
class Article < ActiveRecord::Base class Article < ActiveRecord::Base
belongs_to :user, :foreign_key => 'created_by'
before_create :b_create before_create :b_create
before_update :b_update
before_destroy :b_destroy before_destroy :b_destroy
def b_create def b_create
self.created_by = current_user.id self.rate = 0.0
self.updated_by = current_user.id
end
def b_update
self.updated_by = current_user.id
end end
def b_destroy def b_destroy
#ToDo destroy comments #ToDo destroy comments
end end
def self.created def created
"#{self.email} (#{self.created_at})" "#{self.user.email} (#{self.created_at})"
end end
end end

View File

@ -1,2 +1,3 @@
# encoding: UTF-8
class Comment < ActiveRecord::Base class Comment < ActiveRecord::Base
end end

View File

@ -1,4 +1,6 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
has_many :articles, :foreign_key => 'created_by'
# Include default devise modules. Others available are: # Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable # :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable,

View File

@ -1,6 +1,6 @@
<%- model_class = Article -%> <%- model_class = Article -%>
<div class="page-header"> <div class="page-header">
<h1><%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1> <h1><%=t 'articles' %></h1>
</div> </div>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
@ -11,8 +11,6 @@
<th><%= model_class.human_attribute_name(:rate) %></th> <th><%= model_class.human_attribute_name(:rate) %></th>
<th><%= model_class.human_attribute_name(:active) %></th> <th><%= model_class.human_attribute_name(:active) %></th>
<th><%= model_class.human_attribute_name(:created_by) %></th> <th><%= model_class.human_attribute_name(:created_by) %></th>
<th><%= model_class.human_attribute_name(:updated_by) %></th>
<th><%= model_class.human_attribute_name(:created_at) %></th>
<th><%=t '.actions', :default => t("helpers.actions") %></th> <th><%=t '.actions', :default => t("helpers.actions") %></th>
</tr> </tr>
</thead> </thead>
@ -24,10 +22,10 @@
<td><%= article.content %></td> <td><%= article.content %></td>
<td><%= article.rate %></td> <td><%= article.rate %></td>
<td><%= article.active %></td> <td><%= article.active %></td>
<td><%= article.created_by %></td> <td><%= article.created %></td>
<td><%= article.updated_by %></td>
<td><%=l article.created_at %></td>
<td> <td>
<%= link_to t('.more', :default => t("helpers.links.more")),
article_path(article), :class => 'btn btn-info btn-xs' %>
<%= link_to t('.edit', :default => t("helpers.links.edit")), <%= link_to t('.edit', :default => t("helpers.links.edit")),
edit_article_path(article), :class => 'btn btn-default btn-xs' %> edit_article_path(article), :class => 'btn btn-default btn-xs' %>
<%= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= link_to t('.destroy', :default => t("helpers.links.destroy")),

View File

@ -18,6 +18,6 @@ module Devblog
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de config.i18n.default_locale = :pl
end end
end end

View File

@ -1,18 +1,32 @@
#default: &default
# adapter: sqlite3
# database:
# pool: 5
# timeout: 5000
#
#development:
# <<: *default
# database: db/development.sqlite3
#
#production:
# <<: *default
# database: db/production.sqlite3
#
#test:
# <<: *default
# database: db/test.sqlite3
default: &default default: &default
adapter: mysql2 adapter: mysql2
encoding: utf8 encoding: utf8
pool: 5 pool: 5
timeout: 5000
username: devblog_db username: devblog_db
password: YT29JEeP4t03ECV password: YT29JEeP4t03ECV
timeout: 5000
development: development:
<<: *default <<: *default
database: devblog_dev database: devblog_dev
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: test:
<<: *default <<: *default
database: devblog_test database: devblog_test

View File

@ -0,0 +1,60 @@
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
pl:
devise:
confirmations:
confirmed: "Twoje konto zostało potwierdzone. Proszę się zalogować."
confirmed_and_signed_in: "Twoje konto zostało potwierdzone i zostałeś zalogowany"
send_instructions: "Za kilka minut otrzymasz na e-maila instrukcję jak potwierdzić swoje konto."
send_paranoid_instructions: "Jeśli Twój e-mail istnieje w bazie, za chwilę otrzymasz instrukcję aktywacji konta."
failure:
already_authenticated: "Jesteś już zalogowany."
inactive: "Twoje konto nie jest jeszcze aktywne."
invalid: "Niepoprawny e-mail lub hasło."
invalid_token: "Niepoprawny token uwierzytelnienia."
locked: "Twoje konto jest zablokowane."
not_found_in_database: "Niepoprawny e-mail lub hasło."
timeout: "Sesja wygasła - zaloguj się ponownie, aby kontynuować."
unauthenticated: "Zaloguj się lub załóż konto, aby kontynuować."
unconfirmed: "Nie aktywowałeś jeszcze swojego konta - sprawdź swój e-mail."
mailer:
confirmation_instructions:
subject: "Instrukcja aktywacji konta"
reset_password_instructions:
subject: "Instrukcja ustawienia nowego hasła"
unlock_instructions:
subject: "Instrukcja odblokowania konta"
omniauth_callbacks:
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
success: "Successfully authenticated from %{kind} account."
passwords:
no_token: "Nie masz dostępu do tej strony, ponieważ prawdopodobnie nie pochodzisz z e-maila resetowania hasła. Jeśli pochodzisz z e-maila resetowania hasła, prosimy upewnić się, że używasz pełnego podanego adresu URL."
send_instructions: "Za chwilę wyślemy instrukcję zmiany hasła na Twój adres e-mail."
send_paranoid_instructions: "Jeśli Twój e-mail istnieje w bazie, za chwilę otrzymasz instrukcję zmiany hasła."
updated: "Zmieniłeś swoje hasło. Zostałeś automatycznie zalogowany."
updated_not_active: "Zmieniłeś swoje hasło."
registrations:
destroyed: "Usunąłeś swoje konto."
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ść instrukcją aktywacji konta została wysłana na Twój adres e-mail."
update_needs_confirmation: "Aby potwierdzić zmiany, musimy zweryfikować Twój nowy adres e-mail. Za chwilę wyślemy instrukcję na nowy adres."
updated: "Zaktualizowałeś swoje dane."
sessions:
signed_in: "Witaj!"
signed_out: "Wylogowałeś się. Zapraszamy ponownie!"
unlocks:
send_instructions: "Za chwilę wyślemy instrukcję odblokowania konta na Twój adres e-mail."
send_paranoid_instructions: "Jeśli Twoje konto istnieje w naszej bazie, otrzymasz zaraz e-mail z instrukcją jak odblokować swoje konto."
unlocked: "Twoje konto zostało odblokowane."
errors:
messages:
already_confirmed: "zostało już potwierdzone, prosimy się zalogować"
confirmation_period_expired: "musi być potwierdzone w %{period}, poproś o nowy"
expired: "stracił ważność, wyślij zapytanie o nowy"
not_found: "nie znaleziono"
not_locked: "nie był zablokowany"
not_saved:
one: "Jeden błąd nie pozolił na zapisanie %{resource}:"
other: "%{resource} nie został zapisany z powodu następujących (%{count}) błędów:"

View File

@ -16,6 +16,7 @@ en:
destroy: "Delete" destroy: "Delete"
new: "New" new: "New"
edit: "Edit" edit: "Edit"
more: "More"
titles: titles:
edit: "Edit %{model}" edit: "Edit %{model}"
save: "Save %{model}" save: "Save %{model}"

View File

@ -0,0 +1,24 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
pl:
breadcrumbs:
application:
root: "Index"
pages:
pages: "Strony"
helpers:
actions: "Akcje"
links:
back: "Wstecz"
cancel: "Anuluj"
confirm: "Czy jesteś pewny?"
destroy: "Usuń"
new: "Nowy"
edit: "Edycja"
more: "Więcej"
titles:
edit: "Edycja %{model}"
save: "Zapisz %{model}"
new: "Nowy %{model}"
delete: "Usuń %{model}"

64
config/locales/pl.yml Normal file
View File

@ -0,0 +1,64 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
pl:
hello: "Witaj Świecie"
# Nazwy modeli
articles: "Artykuły"
comments: "Komentarze"
activerecord:
errors:
header:
one: "%{model} nie został zachowany z powodu jednego błędu"
other: "%{model} nie został zachowany z powodu %{count} błędów"
body: "Błędy dotyczą następujących pól:"
messages:
inclusion: "nie znajduje się na liście dopuszczalnych wartości"
exclusion: "znajduje się na liście zabronionych wartości"
invalid: "jest nieprawidłowe"
confirmation: "nie zgadza się z potwierdzeniem"
accepted: "musi być zaakceptowane"
empty: "nie może być puste"
blank: "nie może być puste"
too_long: "jest za długie (maksymalnie %{count} znaków)"
too_short: "jest za krótkie (minimalnie %{count} znaków)"
wrong_length: "jest nieprawidłowej długości (powinna wynosić %{count} znaków)"
taken: "zostało już zajęte"
not_a_number: "nie jest liczbą"
not_an_integer: "nie jest liczbą"
greater_than: "musi być większe niż %{count}"
greater_than_or_equal_to: "musi być większe lub równe %{count}"
equal_to: "musi być równe %{count}"
less_than: "musi być mniejsze niż %{count}"
less_than_or_equal_to: "musi być mniejsze lub równe %{count}"
odd: "musi być nieparzyste"
even: "musi być parzyste"
attributes:
article:
name: "Artykuły"
title: "Tytuł"
content: "Treść"
rate: "Ocena"
active: "Aktywny"
created_by: "Utworzony przez"
city: "'Miasto'"