Add spanish locales and gravatar options

This commit is contained in:
2026-03-09 11:17:25 -05:00
parent 2711edb167
commit 4e1d3bd052
32 changed files with 640 additions and 106 deletions
+21 -6
View File
@@ -13,7 +13,20 @@ class ApplicationController < ActionController::Base
rescue_from SimplyStored::RecordNotFound, with: :show_404
private
# protected
#
# def after_sign_in_path_for(resource)
# case resource
# when 'user' then Mozo.user_url
# else
# main_app.root_path
# end
# # Customize the redirect path here
# # For example, redirect to a dashboard page
# dashboard_path || root_path
# end
#
private
def authenticate_employee!
if auth_token = params[:auth_token].presence || request.headers['HTTP_AUTH_TOKEN'].presence
@@ -67,8 +80,9 @@ private
end
def set_locale
#session[:locale] = (params[:locale].presence || session[:locale] || Rails.configuration.i18n.default_locale).to_sym
I18n.locale = params[:locale].presence.try(:to_sym) || Rails.configuration.i18n.default_locale
session[:locale] = (params[:locale].presence || session[:locale] || Rails.configuration.i18n.default_locale).to_sym
I18n.locale = session[:locale]
# I18n.locale = params[:locale].presence.try(:to_sym) || Rails.configuration.i18n.default_locale
end
def _render_with_renderer_json(resource, options)
@@ -98,9 +112,10 @@ private
def after_sign_in_path_for(resource)
case resource
when Employee then supplier_root_path
when Administrator then cmtool.root_path
else root_path
when User then Mozo.user_url
when Employee then Mozo.supplier_url
when Administrator then cmtool.root_path
else root_path
end
end
@@ -1,13 +0,0 @@
# class RegistrationsController < Devise::RegistrationsController
# protected
#
# #def after_sign_up_path(resource)
# #end
#
# private
#
# # override devise internal to allow name as sign_up param
# def sign_up_params
# params.require(resource_name).permit resource_class.authentication_keys + [:name, :password, :password_confirmation]
# end
# end
+20 -20
View File
@@ -1,20 +1,20 @@
# class WaiterController < ApplicationController
# layout 'waiter'
# def index
#
# end
#
# def product_categories
# respond_to do |format|
# format.html { redirect_to '/waiter'}
# format.json { render json: ProductCategory.all.include_relation(:product), root: 'product_categories', each_serializer: ProductCategorySerializer }
# end
# end
#
# def order_products
# @table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:table_id])
# @list = List.from_table_by_employee(@table, current_employee)
# @list.place_order products: params[:order], employee: current_employee
# render nothing: true
# end
# end
class WaiterController < ApplicationController
layout 'waiter'
def index
end
def product_categories
respond_to do |format|
format.html { redirect_to '/waiter'}
format.json { render json: ProductCategory.all.include_relation(:product), root: 'product_categories', each_serializer: ProductCategorySerializer }
end
end
def order_products
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:table_id])
@list = List.from_table_by_employee(@table, current_employee)
@list.place_order products: params[:order], employee: current_employee
render nothing: true
end
end
+4 -1
View File
@@ -19,7 +19,10 @@ class Employee
end
#view :by_confirmation_token, key: :confirmation_token # devise confirmable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable #, :registerable #, :confirmable
devise_plugins = [:database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable] #, :omniauthable, {omniauth_providers: [:facebook, :instagram]}] #, :token_authenticatable , :registerable
devise_plugins -= [:trackable] if Rails.env.test? # creates conflicts
devise *devise_plugins
# devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable #, :registerable #, :confirmable
property :unconfirmed_email
property :name
+1 -1
View File
@@ -219,7 +219,7 @@ class Supplier
private
def add_section_on_create
@section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title')
@section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title', default: nil) || 'Room'
end
+6
View File
@@ -6,6 +6,7 @@ class User
property :name
property :active_list_id
property :admin, type: :boolean, default: false
property :email_sha256
#FACEBOOK
property :provider
@@ -26,6 +27,7 @@ class User
validates_uniqueness_of :email
before_save :ensure_authentication_token
before_create :set_email_sha256
#has_many :error_logs
has_many :user_feedbacks
@@ -150,6 +152,10 @@ class User
reset_authentication_token! if authentication_token.blank?
end
def set_email_sha256
self.email_sha256 = Digest::SHA256.hexdigest email.to_s.strip.downcase
end
def self.authentication_token
SecureRandom.hex(24)
end
+1 -1
View File
@@ -1,5 +1,5 @@
class Suppliers::UserSerializer
include Mozo::SupplierBaseSerializer
attributes :email, :provider, :uid, :avatar, :number_of_lists_at_supplier
attributes :email, :email_sha256, :provider, :uid, :avatar, :number_of_lists_at_supplier
attribute(:name) { object.supplier_name }
end
+1 -1
View File
@@ -1,6 +1,6 @@
class Users::UserSerializer
include Mozo::UserBaseSerializer
attributes :email, :provider, :uid, :avatar
attributes :email, :email_sha256, :provider, :uid, :avatar
attribute(:name){ object.friends_name }
end
@@ -0,0 +1,11 @@
h2= t('devise.employee.confirmations.title')
= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
= f.label :email, class: 'control-label'
.controls
= f.email_field :email
.control-group
.controls
= f.submit t('devise.employee.confirmations.button'), class: 'button'
= render 'employees/devise/links'
@@ -0,0 +1,23 @@
dl.devise-links
- devise_mapping = Devise.mappings[resource_name]
dt= t 'devise.links.prefix'
- if controller_name != 'sessions'
dd= link_to t('devise.employee.sign_in.link'), new_session_path(resource_name), class: ['devise-link', 'new-session']
- if devise_mapping.registerable? && controller_name != 'registrations'
dd= link_to t('devise.employee.registrations.link'), new_registration_path(resource_name), class: ['devise-link', 'new-registration']
- if resource_name == :employee and controller_name != 'new_suppliers'
dd= link_to t('devise.employee.registrations.link'), new_suppliers_path, class: ['devise-link', 'new-registration']
- if devise_mapping.recoverable? && controller_name != 'passwords'
dd= link_to t('devise.employee.passwords.link'), new_password_path(resource_name), class: ['devise-link', 'forgot-password']
- if devise_mapping.confirmable? && controller_name != 'confirmations'
dd= link_to t('devise.employee.confirmations.did_not_receive_instructions_link'), new_confirmation_path(resource_name), class: ['devise-link', 'did-not-receive-instructions']
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
dd= link_to t('devise.employee.unlocks.did_not_receive_instructions_link'), new_unlock_path(resource_name), class: ['devise-link', 'did-not-receive-instructions']
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
dd= link_to t('devise.employee.omniauth_callbacks.sign_in_with', provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider), class: ['devise-link', 'omniauth', provider]
+12 -10
View File
@@ -1,12 +1,14 @@
h2= t('devise.passwords.edit.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {method: :put}) do |f|
h2= t('devise.employee.passwords.edit.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal', method: :put}) do |f|
= devise_error_messages!
= f.hidden_field :reset_password_token
= f.row :password
.form-label= f.label :password
.form-field= f.password_field :password
= f.row :password_confirmation
.form-label= f.label :password_confirmation
.form-field= f.password_field :password_confirmation
.form-row= f.submit t('devise.passwords.edit.button'), class: 'button'
= render "devise/links"
.control-group
= f.label :password, class: 'control-label'
.controls= f.password_field :password
.control-group
= f.label :password_confirmation, class: 'control-label'
.controls= f.password_field :password_confirmation
.control-group
.controls
= f.submit t('devise.employee.passwords.edit.button'), class: 'button'
= render 'employees/devise/links'
+9 -7
View File
@@ -1,8 +1,10 @@
h2= t('devise.passwords.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |f|
h2= t('devise.employee.passwords.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
= f.row :email do
.form-label= f.label :email, class: 'control-label'
.form-field= f.email_field :email, autofocus: true
.form-row.form-actions= f.submit t('devise.passwords.button'), class: 'button'
= render "devise/links"
.control-group
= f.label :email, class: 'control-label'
.controls= f.email_field :email
.control-group
.controls
= f.submit t('devise.employee.passwords.button'), class: 'button'
= render 'employees/devise/links'
@@ -0,0 +1,25 @@
<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><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, :autocomplete => "off" %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password %></div>
<div><%= f.submit "Update" %></div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
<%= link_to "Back", :back %>
@@ -0,0 +1,22 @@
h2= t('devise.employee.registrations.title')
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
= f.label :name, class: 'control-label'
.controls= f.text_field :name
.control-group
= f.label :email, class: 'control-label'
.controls
= f.email_field :email
- if f.object.errors[:email].present?
small.error= f.object.errors[:email].to_sentence
.control-group
= f.label :password, class: 'control-label'
.controls= f.password_field :password
.control-group
= f.label :password_confirmation, class: 'control-label'
.controls= f.password_field :password_confirmation
.control-group
.controls
= f.submit t('devise.employee.registrations.button'), class: 'button'
= render 'employees/devise/links'
@@ -0,0 +1,25 @@
h2= t('devise.employee.sign_in.title')
= form_for(resource, :as => resource_name, :url => session_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
= f.label :email, class: 'control-label'
.controls
= f.email_field :email
- if f.object.errors[:email].present?
small.error= f.object.errors[:email].to_sentence
.control-group
= f.label :password, class: 'control-label'
.controls
= f.password_field :password
- if f.object.errors[:password].present?
small.error= f.object.errors[:password].to_sentence
.control-group
.controls
= f.label :remember_me do
= f.check_box :remember_me
|&nbsp;
= t('devise.employee.sign_in.remember_me')
.control-group
.controls
= f.submit t('devise.employee.sign_in.button'), class: 'button'
= render 'employees/devise/links'
+1 -1
View File
@@ -38,4 +38,4 @@
.row
.small-12.columns== @page.footer
= render "devise/links", resource_name: :employee
/= render "devise/links", resource_name: :employee