Create new profiles
This commit is contained in:
parent
d8986f542d
commit
59d1bca0dc
@ -1,9 +1,10 @@
|
|||||||
module Management
|
module Management
|
||||||
# TODO (2015-07-28) How to create a new profile for a particular profile if given a user? What would be the interface?
|
|
||||||
class PersonalProfilesController < ManagementController
|
class PersonalProfilesController < ManagementController
|
||||||
def index
|
def index
|
||||||
@conference = find_conference
|
@conference = find_conference
|
||||||
@profiles = @conference.participant_profiles
|
|
||||||
|
# TODO @conference.participants
|
||||||
|
@users = User.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def toggle_admin
|
def toggle_admin
|
||||||
@ -25,6 +26,25 @@ module Management
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@conference = find_conference
|
||||||
|
@profile = @conference.participant_profiles.
|
||||||
|
build(user_id: params[:user_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@conference = find_conference
|
||||||
|
@profile = PersonalProfile.new(profile_params)
|
||||||
|
@profile.conference = @conference
|
||||||
|
|
||||||
|
if @profile.save
|
||||||
|
flash[:notice] = 'Profile was successfully created.'
|
||||||
|
redirect_to action: :index
|
||||||
|
else
|
||||||
|
render action: :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@conference = find_conference
|
@conference = find_conference
|
||||||
@profile = find_profile
|
@profile = find_profile
|
||||||
@ -70,7 +90,7 @@ module Management
|
|||||||
:public_email,
|
:public_email,
|
||||||
:github,
|
:github,
|
||||||
:twitter,
|
:twitter,
|
||||||
user_attributes: [:id, :email]
|
:user_id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,6 +19,10 @@ class Conference < ActiveRecord::Base
|
|||||||
|
|
||||||
after_create :create_call_for_participation
|
after_create :create_call_for_participation
|
||||||
|
|
||||||
|
def participants
|
||||||
|
events.where(conference_id: id).map(&:user)
|
||||||
|
end
|
||||||
|
|
||||||
def submissions_grouped_by_day
|
def submissions_grouped_by_day
|
||||||
submissions = events.group('date(events.created_at)').select('events.created_at, count(events.id) as number')
|
submissions = events.group('date(events.created_at)').select('events.created_at, count(events.id) as number')
|
||||||
submissions.group_by { |s| s.created_at.to_date }
|
submissions.group_by { |s| s.created_at.to_date }
|
||||||
|
32
app/views/management/personal_profiles/_form.html.slim
Normal file
32
app/views/management/personal_profiles/_form.html.slim
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
= simple_nested_form_for [:management, @conference, @profile], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f|
|
||||||
|
= f.input :user_id, as: :hidden
|
||||||
|
|
||||||
|
.panel.panel-primary
|
||||||
|
.panel-heading
|
||||||
|
h1.panel-title
|
||||||
|
= t 'views.user.info'
|
||||||
|
= link_to icon(:eye), [:management, @conference, @profile], class: 'btn btn-xs btn-info pull-right'
|
||||||
|
|
||||||
|
.panel-body
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
- if f.object.picture.present?
|
||||||
|
.col-sm-offset-3.col-sm-9
|
||||||
|
= image_tag f.object.picture.medium.url, class: 'img-thumbnail'
|
||||||
|
|
||||||
|
= f.input :picture, wrapper: :horizontal_file_input
|
||||||
|
|
||||||
|
-# Required
|
||||||
|
= f.input :first_name
|
||||||
|
= f.input :last_name
|
||||||
|
= f.input :mobile_phone
|
||||||
|
= f.input :biography
|
||||||
|
|
||||||
|
-# Optional
|
||||||
|
= f.input :organisation
|
||||||
|
= f.input :public_email
|
||||||
|
= f.input :github
|
||||||
|
= f.input :twitter
|
||||||
|
|
||||||
|
.panel-footer.text-right
|
||||||
|
= f.submit class: 'btn btn-primary'
|
@ -4,38 +4,4 @@
|
|||||||
|
|
||||||
.row
|
.row
|
||||||
.col-lg-12
|
.col-lg-12
|
||||||
= simple_nested_form_for [:management, @conference, @profile], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f|
|
= render 'form'
|
||||||
.panel.panel-primary
|
|
||||||
.panel-heading
|
|
||||||
h1.panel-title
|
|
||||||
= t 'views.user.info'
|
|
||||||
= link_to icon(:eye), [:management, @conference, @profile], class: 'btn btn-xs btn-info pull-right'
|
|
||||||
|
|
||||||
.panel-body
|
|
||||||
.row
|
|
||||||
.col-lg-12
|
|
||||||
= f.simple_fields_for :user do |ff|
|
|
||||||
= ff.input :email
|
|
||||||
hr
|
|
||||||
.row
|
|
||||||
.col-lg-12
|
|
||||||
- if f.object.picture.present?
|
|
||||||
.col-sm-offset-3.col-sm-9
|
|
||||||
= image_tag f.object.picture.medium.url, class: 'img-thumbnail'
|
|
||||||
|
|
||||||
= f.input :picture, wrapper: :horizontal_file_input
|
|
||||||
|
|
||||||
-# Required
|
|
||||||
= f.input :first_name
|
|
||||||
= f.input :last_name
|
|
||||||
= f.input :mobile_phone
|
|
||||||
= f.input :biography
|
|
||||||
|
|
||||||
-# Optional
|
|
||||||
= f.input :organisation
|
|
||||||
= f.input :public_email
|
|
||||||
= f.input :github
|
|
||||||
= f.input :twitter
|
|
||||||
|
|
||||||
.panel-footer.text-right
|
|
||||||
= f.submit class: 'btn btn-primary'
|
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
th = User.human_attribute_name :admin
|
th = User.human_attribute_name :admin
|
||||||
th.actions
|
th.actions
|
||||||
tbody
|
tbody
|
||||||
- @profiles.each do |profile|
|
- @users.each do |user|
|
||||||
- user = profile.user
|
- profile = user.personal_profile(@conference)
|
||||||
|
|
||||||
|
- if profile.present?
|
||||||
tr
|
tr
|
||||||
td= image_tag(profile.picture.thumb.url)
|
td= image_tag(profile.picture.thumb.url)
|
||||||
td= profile.name
|
td= profile.name
|
||||||
@ -28,3 +29,13 @@
|
|||||||
td.actions
|
td.actions
|
||||||
div.btn-group.btn-group-sm
|
div.btn-group.btn-group-sm
|
||||||
= action_buttons(@conference, profile, [:show, :edit, :destroy])
|
= action_buttons(@conference, profile, [:show, :edit, :destroy])
|
||||||
|
|
||||||
|
- else
|
||||||
|
tr
|
||||||
|
td= image_tag(PictureUploader.new.thumb.url)
|
||||||
|
td= user.email
|
||||||
|
td
|
||||||
|
td.actions
|
||||||
|
div.btn-group.btn-group-sm
|
||||||
|
-# TODO translation
|
||||||
|
= link_to 'Създай профил', [:new, :management, @conference, :personal_profile, {user_id: user.id}]
|
||||||
|
7
app/views/management/personal_profiles/new.html.slim
Normal file
7
app/views/management/personal_profiles/new.html.slim
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
- content_for :title
|
||||||
|
-# TODO translation
|
||||||
|
=> t 'actions.new.title', model: User.model_name.human
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
= render 'form'
|
Loading…
x
Reference in New Issue
Block a user