Create new profiles
This commit is contained in:
parent
d8986f542d
commit
59d1bca0dc
|
@ -1,9 +1,10 @@
|
|||
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
|
||||
def index
|
||||
@conference = find_conference
|
||||
@profiles = @conference.participant_profiles
|
||||
|
||||
# TODO @conference.participants
|
||||
@users = User.all
|
||||
end
|
||||
|
||||
def toggle_admin
|
||||
|
@ -25,6 +26,25 @@ module Management
|
|||
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
|
||||
@conference = find_conference
|
||||
@profile = find_profile
|
||||
|
@ -70,7 +90,7 @@ module Management
|
|||
:public_email,
|
||||
:github,
|
||||
:twitter,
|
||||
user_attributes: [:id, :email]
|
||||
:user_id
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,6 +19,10 @@ class Conference < ActiveRecord::Base
|
|||
|
||||
after_create :create_call_for_participation
|
||||
|
||||
def participants
|
||||
events.where(conference_id: id).map(&:user)
|
||||
end
|
||||
|
||||
def submissions_grouped_by_day
|
||||
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 }
|
||||
|
|
|
@ -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
|
||||
.col-lg-12
|
||||
= simple_nested_form_for [:management, @conference, @profile], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f|
|
||||
.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'
|
||||
= render 'form'
|
||||
|
|
|
@ -12,19 +12,30 @@
|
|||
th = User.human_attribute_name :admin
|
||||
th.actions
|
||||
tbody
|
||||
- @profiles.each do |profile|
|
||||
- user = profile.user
|
||||
- @users.each do |user|
|
||||
- profile = user.personal_profile(@conference)
|
||||
|
||||
tr
|
||||
td= image_tag(profile.picture.thumb.url)
|
||||
td= profile.name
|
||||
td.boolean-col
|
||||
= link_to [:toggle_admin, :management, @conference, profile], method: :put do
|
||||
- if user.admin?
|
||||
.btn.btn-primary= icon('circle-o')
|
||||
- else
|
||||
.btn.btn-success= icon('dot-circle-o')
|
||||
- if profile.present?
|
||||
tr
|
||||
td= image_tag(profile.picture.thumb.url)
|
||||
td= profile.name
|
||||
td.boolean-col
|
||||
= link_to [:toggle_admin, :management, @conference, profile], method: :put do
|
||||
- if user.admin?
|
||||
.btn.btn-primary= icon('circle-o')
|
||||
- else
|
||||
.btn.btn-success= icon('dot-circle-o')
|
||||
|
||||
td.actions
|
||||
div.btn-group.btn-group-sm
|
||||
= action_buttons(@conference, profile, [:show, :edit, :destroy])
|
||||
td.actions
|
||||
div.btn-group.btn-group-sm
|
||||
= 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}]
|
||||
|
|
|
@ -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…
Reference in New Issue