Commit 61c40a43 by Mykhailo Makohin

start to translate index page

parent 3afe7f1e
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options
{ locale: I18n.locale }
end
end
......@@ -14,10 +14,11 @@ class UsersController < ApplicationController
def create
@user = User.find_or_create_by(user_params)
@user.skip_password_validation = true
if @user.save
redirect_to root_path
else
render 'home#index'
redirect_to root_path
end
end
......@@ -52,7 +53,7 @@ class UsersController < ApplicationController
end
def user_params
params.require(:user).permit(:email, :name)
params.require(:user).permit(:email, :name, :location)
end
end
\ No newline at end of file
class User < ApplicationRecord
attr_accessor :skip_password_validation
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable, :omniauthable,
......@@ -12,18 +13,6 @@ class User < ApplicationRecord
end
end
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
# user.email = auth.info.email
user.password = Devise.friendly_token[0,20]
user.name = auth.info.name # assuming the user model has a name
user.image = auth.info.image # assuming the user model has an image
# If you are using confirmable and the provider(s) you use validate emails,
# uncomment the line below to skip the confirmation emails.
# user.skip_confirmation!
end
end
def self.from_omniauth(access_token)
data = access_token.info
user = User.where(email: data['email']).first
......@@ -37,4 +26,11 @@ class User < ApplicationRecord
end
user
end
protected
def password_required?
return false if skip_password_validation
super
end
end
......@@ -6,10 +6,7 @@
#1.tab-pane.tab-pane_people.active
.main_head_title
= image_tag ("logo_lg.png")
%h1
Середовище
%br/
Тепле Місто
%h1 Середовище Тепле Місто
.title_highlighted
Простір міста формюють його жителі
.tab-pane_content
......@@ -207,8 +204,8 @@
%a.round_link.soc_link_tw{:href => "#"}
%i.icon.icon_tw
.lang
%a.lang_link{:href => "#"} ENG
%a.lang_link.active{:href => "#"} UA
%a.lang_link{href: "/en"} ENG
%a.lang_link.active{href: "/uk"} UA
.section.section_grants
.container
.row
......
......@@ -13,22 +13,21 @@
#bs-example-navbar-collapse-1.collapse.navbar-collapse
%ul.nav.navbar-nav
%li
%a{:href => "#"} про палатформу
%a{:href => "#"}= t ("header.platfform")
%li
%a{:href => "#"} Ґранти
%a{:href => "#"}= t ("header.grants")
%li
%a{:href => "#"} Проекти
%a{:href => "#"}= t ("header.projects")
%li
%a{:href => "#"} Партнери
%a{:href => "#"}= t ("header.partners")
%li
%a{:href => "#"} DIGITAL WORKSHOP
%a{:href => "#"}= t ("header.digital")
%li
%a{:href => "#"} Про нас
%a{:href => "#"}= t ("header.about_us")
%li
%a{:href => "#"} Новини
-if user_signed_in?
%a{:href => "#"}= t ("header.news")
%li
%a{:href => "#"} Звіти
%a{:href => "#"}= t ("header.reports")
%li
%a{:href => "#"} connectif
%li
......@@ -36,7 +35,7 @@
= link_to('Logout', destroy_user_session_path, method: :delete)
%ul.nav.nav-tabs.nav_btns
%li.active
%a{"data-toggle" => "tab", :href => "#1"} Люди
%a{"data-toggle" => "tab", :href => "#1"}= t 'header.people'
%li
%a{"data-toggle" => "tab", :href => "#2"} Бізнеси
.show_tip
......
= simple_form_for :user, url: users_path, method: :post, remote: true, authenticity_token: true do |f|
= simple_form_for :user, url: users_path, authenticity_token: true do |f|
#modal3.modal.fade.modal_styled{"aria-labelledby" => "modalLabel", :role => "dialog", :tabindex => "-1"}
.modal-dialog{:role => "document"}
.modal-content
......@@ -30,20 +30,19 @@
.field_wrap
= f.input :name, class: 'form-control', label: false
.form-group
%label{:for => "id_4"}
%span.asterisk> *
%label{:for => "user_location"}
Населений пункт
.field_wrap
%input#id_4.form-control{:type => "text"}/
= f.input :location, class: 'form-control', label: ""
.col-sm-3.modal-body_registration
%h4.modal_subtitle
Швидка реєстрація
.soc_btn_wrap.clearfix
%a.soc_btn.soc_btn_fb{:href => "#"}
%a.soc_btn.soc_btn_fb{href: "/users/auth/facebook"}
%i.icon.icon_fb
%a.soc_btn.soc_btn_tw{:href => "#"}
%a.soc_btn.soc_btn_tw{href: "/users/auth/linkedin"}
%i.icon.icon_tw
%a.soc_btn.soc_btn_google{:href => "/users/auth/google_oauth2"}
%a.soc_btn.soc_btn_google{href: "/users/auth/google_oauth2"}
%i.icon.icon_google
.text-center
= f.button :submit, "Register Now", class: "btn btn-success btn-lg"
......@@ -8,8 +8,5 @@ Bundler.require(*Rails.groups)
module WarmCity
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
end
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
end
......@@ -24,7 +24,7 @@ Devise.setup do |config|
config.sign_out_via = [:delete, :get]
config.omniauth :facebook, "2429624190692901", "03da24c1517b0bfa4acc70852f61fb60",
config.omniauth :facebook, "395576994435405", "22b5985763d0abbe82ec69f32ece46a6",
callback_url: "http://localhost:3000/users/auth/facebook/callback",
scope: 'email', info_fields: 'email,name'
......
# 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.
en:
hello: "Hello world"
en:
header:
platfform: 'about platform'
grants: 'grants'
projects: 'projects'
partners: 'partners'
digital: 'digital workshop'
about_us: 'about us'
news: 'news'
reports: 'reports'
people: 'People'
businesses: 'Businesses'
\ No newline at end of file
uk:
header:
platfform: 'про платформу'
grants: 'Ґранти'
projects: 'Проекти'
partners: 'Партнери'
digital: 'DIGITAL WORKSHOP'
about_us: 'Про нас'
news: 'Новини'
reports: 'Звіти'
people: 'Люди'
businesses: 'Бізнеси'
uk:
# header:
# platfform: 'про платформу'
\ No newline at end of file
uk:
header:
platfform: 'про платформу'
en:
header:
platfform: 'about platform'
\ No newline at end of file
uk:
header:
platfform: 'про платформу'
Rails.application.routes.draw do
scope "(:locale)", locale: /en|uk/ do
root 'home#index'
devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
resources :users
end
devise_for :users, controllers: {omniauth_callbacks: "users/omniauth_callbacks",
registrations: "users"}
end
......@@ -3,6 +3,7 @@ class AddOmniauthToUsers < ActiveRecord::Migration[5.0]
add_column :users, :provider, :string
add_column :users, :uid, :string
add_column :users, :name, :string
add_column :users, :location, :string
add_column :users, :image, :text
end
end
......@@ -23,6 +23,7 @@ ActiveRecord::Schema.define(version: 20190829110429) do
t.string "provider"
t.string "uid"
t.string "name"
t.string "location"
t.text "image", limit: 65535
t.index ["email"], name: "index_users_on_email", unique: true, using: :btree
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment