Speaker profile #2
3
Gemfile
3
Gemfile
|
@ -24,6 +24,9 @@ gem 'simple_form'
|
||||||
# Phone validation
|
# Phone validation
|
||||||
gem 'phony_rails'
|
gem 'phony_rails'
|
||||||
|
|
||||||
|
# Picture uploads
|
||||||
|
gem 'carrierwave'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'spring'
|
gem 'spring'
|
||||||
gem 'spring-commands-rspec'
|
gem 'spring-commands-rspec'
|
||||||
|
|
|
@ -36,6 +36,11 @@ GEM
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
xpath (~> 2.0)
|
xpath (~> 2.0)
|
||||||
|
carrierwave (0.10.0)
|
||||||
|
activemodel (>= 3.2.0)
|
||||||
|
activesupport (>= 3.2.0)
|
||||||
|
json (>= 1.7)
|
||||||
|
mime-types (>= 1.16)
|
||||||
celluloid (0.15.2)
|
celluloid (0.15.2)
|
||||||
timers (~> 1.1.0)
|
timers (~> 1.1.0)
|
||||||
choice (0.1.6)
|
choice (0.1.6)
|
||||||
|
@ -221,6 +226,7 @@ PLATFORMS
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
capybara
|
capybara
|
||||||
|
carrierwave
|
||||||
coffee-rails
|
coffee-rails
|
||||||
devise
|
devise
|
||||||
devise-i18n
|
devise-i18n
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def configure_permitted_parameters
|
def configure_permitted_parameters
|
||||||
devise_parameter_sanitizer.for(:account_update) do |u|
|
devise_parameter_sanitizer.for(:account_update) do |u|
|
||||||
u.permit(:email, :password, :password_confirmation, :current_password, speaker_profile_attributes: [:first_name, :last_name, :public_email, :organisation, :github, :twitter, :mobile_phone, :biography])
|
u.permit(:email, :password, :password_confirmation, :current_password, speaker_profile_attributes: [:first_name, :last_name, :public_email, :organisation, :github, :twitter, :mobile_phone, :biography, :picture, :id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class SessionsController < Devise::SessionsController
|
||||||
|
def after_sign_in_path_for(user)
|
||||||
|
if user.speaker_profile.present?
|
||||||
|
stored_location_for(user) || signed_in_root_path(user)
|
||||||
|
else
|
||||||
|
edit_user_registration_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,7 +3,7 @@ class SpeakerProfile < ActiveRecord::Base
|
||||||
|
|
||||||
validates :first_name, presence: true
|
validates :first_name, presence: true
|
||||||
validates :last_name, presence: true
|
validates :last_name, presence: true
|
||||||
validates :photo_url, presence: true
|
validates :picture, presence: true
|
||||||
validates :mobile_phone, phony_plausible: true, presence: true
|
validates :mobile_phone, phony_plausible: true, presence: true
|
||||||
validates :biography, presence: true
|
validates :biography, presence: true
|
||||||
validates :public_email, format: {with: /\A[^@]+@[^@]+\z/}, allow_blank: true
|
validates :public_email, format: {with: /\A[^@]+@[^@]+\z/}, allow_blank: true
|
||||||
|
@ -12,6 +12,8 @@ class SpeakerProfile < ActiveRecord::Base
|
||||||
|
|
||||||
phony_normalize :mobile_phone, default_country_code: 'BG'
|
phony_normalize :mobile_phone, default_country_code: 'BG'
|
||||||
|
|
||||||
|
mount_uploader :picture, PictureUploader
|
||||||
|
|
||||||
def twitter=(handle)
|
def twitter=(handle)
|
||||||
write_attribute :twitter, handle.gsub(/\A@/,'') if handle
|
write_attribute :twitter, handle.gsub(/\A@/,'') if handle
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
class PictureUploader < CarrierWave::Uploader::Base
|
||||||
|
|
||||||
|
# Include RMagick or MiniMagick support:
|
||||||
|
# include CarrierWave::RMagick
|
||||||
|
# include CarrierWave::MiniMagick
|
||||||
|
|
||||||
|
# Choose what kind of storage to use for this uploader:
|
||||||
|
storage :file
|
||||||
|
# storage :fog
|
||||||
|
|
||||||
|
# Override the directory where uploaded files will be stored.
|
||||||
|
# This is a sensible default for uploaders that are meant to be mounted:
|
||||||
|
def store_dir
|
||||||
|
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||||
|
# def default_url
|
||||||
|
# # For Rails 3.1+ asset pipeline compatibility:
|
||||||
|
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
||||||
|
#
|
||||||
|
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Process files as they are uploaded:
|
||||||
|
# process :scale => [200, 300]
|
||||||
|
#
|
||||||
|
# def scale(width, height)
|
||||||
|
# # do something
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Create different versions of your uploaded files:
|
||||||
|
# version :thumb do
|
||||||
|
# process :resize_to_fit => [50, 50]
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Add a white list of extensions which are allowed to be uploaded.
|
||||||
|
# For images you might use something like this:
|
||||||
|
# def extension_white_list
|
||||||
|
# %w(jpg jpeg gif png)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Override the filename of the uploaded files:
|
||||||
|
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||||
|
# def filename
|
||||||
|
# "something.jpg" if original_filename
|
||||||
|
# end
|
||||||
|
|
||||||
|
end
|
|
@ -1,22 +1,9 @@
|
||||||
h2.entry-title Редакция на акаунт
|
|
||||||
|
|
||||||
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
|
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
|
||||||
= f.error_notification
|
|
||||||
|
|
||||||
.form-inputs
|
|
||||||
h3 Данни за вход в системата
|
|
||||||
= f.input :email, required: true, autofocus: true
|
|
||||||
|
|
||||||
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
|
|
||||||
p Currently waiting confirmation for: #{resource.unconfirmed_email}
|
|
||||||
|
|
||||||
= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false
|
|
||||||
= f.input :password_confirmation, required: false
|
|
||||||
= f.input :current_password, hint: "we need your current password to confirm your changes", required: true
|
|
||||||
|
|
||||||
.form_inputs
|
.form_inputs
|
||||||
h3 Лекторски профил
|
h2.entry-title Лекторски профил
|
||||||
|
= f.error_notification
|
||||||
= f.simple_fields_for :speaker_profile do |ff|
|
= f.simple_fields_for :speaker_profile do |ff|
|
||||||
|
= ff.input :picture, as: :file
|
||||||
= ff.input :first_name
|
= ff.input :first_name
|
||||||
= ff.input :last_name
|
= ff.input :last_name
|
||||||
= ff.input :public_email
|
= ff.input :public_email
|
||||||
|
@ -26,5 +13,17 @@ h2.entry-title Редакция на акаунт
|
||||||
= ff.input :mobile_phone, input_html: {value: resource.speaker_profile.mobile_phone.try(:phony_formatted, format: :international)}
|
= ff.input :mobile_phone, input_html: {value: resource.speaker_profile.mobile_phone.try(:phony_formatted, format: :international)}
|
||||||
= ff.input :biography
|
= ff.input :biography
|
||||||
|
|
||||||
|
.form-inputs
|
||||||
|
h3.entry-title Данни за вход в системата
|
||||||
|
= f.input :email, required: true, autofocus: true
|
||||||
|
|
||||||
|
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
|
||||||
|
p
|
||||||
|
Очаква се потвърждение на: #{resource.unconfirmed_email}
|
||||||
|
|
||||||
|
= f.input :password, autocomplete: "off", hint: "Не попълвайте, ако не желаете да промените паролата си", required: false
|
||||||
|
= f.input :password_confirmation, required: false
|
||||||
|
= f.input :current_password, hint: "Попълнете, ако искате да промените паролата или имейл адреса си.", required: true
|
||||||
|
|
||||||
.form-actions
|
.form-actions
|
||||||
= f.button :submit, 'Обнови'
|
= f.button :submit, 'Обнови'
|
||||||
|
|
|
@ -35,10 +35,12 @@ bg:
|
||||||
attributes:
|
attributes:
|
||||||
user:
|
user:
|
||||||
email: E-mail
|
email: E-mail
|
||||||
|
current_password: Текуща парола
|
||||||
password: Парола
|
password: Парола
|
||||||
password_confirmation: Отново паролата
|
password_confirmation: Отново паролата
|
||||||
remember_me: Запомни ме
|
remember_me: Запомни ме
|
||||||
speaker_profile:
|
speaker_profile:
|
||||||
|
picture: Снимка
|
||||||
first_name: Име
|
first_name: Име
|
||||||
last_name: Фамилия
|
last_name: Фамилия
|
||||||
organisation: Организация
|
organisation: Организация
|
||||||
|
|
|
@ -13,6 +13,7 @@ bg:
|
||||||
password: Парола с дължина между 8 и 128 символа
|
password: Парола с дължина между 8 и 128 символа
|
||||||
password_confirmation: Отново въведената отгоре парола
|
password_confirmation: Отново въведената отгоре парола
|
||||||
speaker_profile:
|
speaker_profile:
|
||||||
|
picture: Ваша снимка
|
||||||
first_name: Малкото Ви име
|
first_name: Малкото Ви име
|
||||||
last_name: Фамилното Ви име
|
last_name: Фамилното Ви име
|
||||||
organisation: Организацията, която представлявате
|
organisation: Организацията, която представлявате
|
||||||
|
|
|
@ -2,7 +2,7 @@ Rails.application.routes.draw do
|
||||||
resources :lectures, only: [:index, :new, :create, :edit, :update, :show]
|
resources :lectures, only: [:index, :new, :create, :edit, :update, :show]
|
||||||
resources :workshops, only: [:index, :new, :create, :edit, :update, :show]
|
resources :workshops, only: [:index, :new, :create, :edit, :update, :show]
|
||||||
|
|
||||||
devise_for :users, controllers: {registrations: 'registrations'}
|
devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions'}
|
||||||
|
|
||||||
resource :user, only: [] do
|
resource :user, only: [] do
|
||||||
resource :speaker_profile, only: [:edit, :update]
|
resource :speaker_profile, only: [:edit, :update]
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RenamePictureUrlToPictureInSpeakerProfiles < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :speaker_profiles, :photo_url, :picture
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue