Compare commits
10 Commits
cd73e4810a
...
a4e9a56f68
| Author | SHA1 | Date |
|---|---|---|
|
|
a4e9a56f68 | |
|
|
3d9f7169be | |
|
|
86a89a0164 | |
|
|
436c6e2f1f | |
|
|
a98786f044 | |
|
|
b1f7a452a3 | |
|
|
eafdb61f2f | |
|
|
2b7ad6b321 | |
|
|
467545c85a | |
|
|
3452a81971 |
|
|
@ -2,4 +2,12 @@ class ApplicationController < ActionController::Base
|
|||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class ArticlesController < ApplicationController
|
||||
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.json
|
||||
|
|
@ -26,7 +26,8 @@ class ArticlesController < ApplicationController
|
|||
# POST /articles.json
|
||||
def create
|
||||
@article = Article.new(article_params)
|
||||
|
||||
@article.created_by = current_user.id
|
||||
@article.updated_by = current_user.id
|
||||
respond_to do |format|
|
||||
if @article.save
|
||||
format.html { redirect_to @article, notice: 'Article was successfully created.' }
|
||||
|
|
@ -63,13 +64,13 @@ class ArticlesController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_article
|
||||
@article = Article.find(params[:id])
|
||||
end
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_article
|
||||
@article = Article.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def article_params
|
||||
params.require(:article).permit(:title, :content, :rate, :active, :created_by, :updated_by)
|
||||
end
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def article_params
|
||||
params.require(:article).permit(:title, :content, :rate, :active, :created_by, :updated_by)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,23 +1,19 @@
|
|||
class Article < ActiveRecord::Base
|
||||
|
||||
belongs_to :user, :foreign_key => 'created_by'
|
||||
|
||||
before_create :b_create
|
||||
before_update :b_update
|
||||
before_destroy :b_destroy
|
||||
|
||||
def b_create
|
||||
self.created_by = current_user.id
|
||||
self.updated_by = current_user.id
|
||||
self.rate = 0.0
|
||||
end
|
||||
|
||||
def b_update
|
||||
self.updated_by = current_user.id
|
||||
end
|
||||
|
||||
def b_destroy
|
||||
#ToDo destroy comments
|
||||
end
|
||||
|
||||
def self.created
|
||||
"#{self.email} (#{self.created_at})"
|
||||
def created
|
||||
"#{self.user.email} (#{self.created_at})"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
# encoding: UTF-8
|
||||
class Comment < ActiveRecord::Base
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
class User < ActiveRecord::Base
|
||||
|
||||
has_many :articles, :foreign_key => 'created_by'
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<%- model_class = Article -%>
|
||||
<div class="page-header">
|
||||
<h1><%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1>
|
||||
<h1><%=t 'articles' %></h1>
|
||||
</div>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
|
|
@ -11,8 +11,6 @@
|
|||
<th><%= model_class.human_attribute_name(:rate) %></th>
|
||||
<th><%= model_class.human_attribute_name(:active) %></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>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -24,10 +22,10 @@
|
|||
<td><%= article.content %></td>
|
||||
<td><%= article.rate %></td>
|
||||
<td><%= article.active %></td>
|
||||
<td><%= article.created_by %></td>
|
||||
<td><%= article.updated_by %></td>
|
||||
<td><%=l article.created_at %></td>
|
||||
<td><%= article.created %></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")),
|
||||
edit_article_path(article), :class => 'btn btn-default btn-xs' %>
|
||||
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ module Devblog
|
|||
|
||||
# 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.default_locale = :de
|
||||
config.i18n.default_locale = :pl
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
adapter: mysql2
|
||||
encoding: utf8
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
username: devblog_db
|
||||
password: YT29JEeP4t03ECV
|
||||
timeout: 5000
|
||||
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
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:
|
||||
<<: *default
|
||||
database: devblog_test
|
||||
|
|
|
|||
|
|
@ -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:"
|
||||
|
|
@ -16,6 +16,7 @@ en:
|
|||
destroy: "Delete"
|
||||
new: "New"
|
||||
edit: "Edit"
|
||||
more: "More"
|
||||
titles:
|
||||
edit: "Edit %{model}"
|
||||
save: "Save %{model}"
|
||||
|
|
|
|||
|
|
@ -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}"
|
||||
|
|
@ -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'"
|
||||
Loading…
Reference in New Issue