Lecture creation
This commit is contained in:
parent
0190ee077f
commit
6728b3d059
|
@ -1,10 +1,19 @@
|
||||||
class LecturesController < ApplicationController
|
class LecturesController < ApplicationController
|
||||||
|
before_filter :authenticate_user!
|
||||||
|
before_action :assign_lecture, only: [:show]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@lecture = Lecture.new
|
@lecture = Lecture.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
head :created
|
@lecture = current_user.lectures.build lecture_params
|
||||||
|
|
||||||
|
if @lecture.save
|
||||||
|
redirect_to @lecture
|
||||||
|
else
|
||||||
|
render :new, status: :unprocessable_entity
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@ -15,4 +24,14 @@ class LecturesController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def assign_lecture
|
||||||
|
@lecture = Lecture.find params[:id]
|
||||||
|
end
|
||||||
|
|
||||||
|
def lecture_params
|
||||||
|
params.require(:lecture).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,7 @@ class Event < ActiveRecord::Base
|
||||||
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
|
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
|
||||||
validates :abstract, presence: true
|
validates :abstract, presence: true
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
|
validates :track, inclusion: { in: (Conference.current.try(:tracks) || []) }
|
||||||
|
|
||||||
belongs_to :track
|
belongs_to :track
|
||||||
has_one :conference, through: :track
|
has_one :conference, through: :track
|
||||||
|
|
|
@ -3,5 +3,8 @@ class User < ActiveRecord::Base
|
||||||
# :lockable, :timeoutable and :omniauthable
|
# :lockable, :timeoutable and :omniauthable
|
||||||
devise :database_authenticatable, :registerable, :confirmable,
|
devise :database_authenticatable, :registerable, :confirmable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
has_one :speaker_profile
|
has_one :speaker_profile
|
||||||
|
has_many :lectures
|
||||||
|
has_many :workshops
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
h1 Предложи нова лекция
|
h1.entry-title Предложи нова лекция
|
||||||
= render 'form'
|
= render 'form'
|
||||||
|
|
|
@ -1,2 +1,20 @@
|
||||||
h1 Lectures#show
|
h1.entry-title Преглед на лекция
|
||||||
p Find me in app/views/lectures/show.html.slim
|
|
||||||
|
h2.lecture-title
|
||||||
|
= @lecture.title
|
||||||
|
span.subtitle = @lecture.subtitle
|
||||||
|
.entry-meta
|
||||||
|
|
|
||||||
|
поток: „#{@lecture.track.name}“,
|
||||||
|
продължителност: #{@lecture.length} мин.
|
||||||
|
|
||||||
|
section.abstract
|
||||||
|
h3 Резюме
|
||||||
|
= simple_format @lecture.abstract
|
||||||
|
|
||||||
|
section.description
|
||||||
|
h3 Описание
|
||||||
|
= simple_format @lecture.description
|
||||||
|
|
||||||
|
- if current_user == @lecture.user
|
||||||
|
= link_to 'Редактирай', edit_lecture_path(@lecture)
|
||||||
|
|
Loading…
Reference in New Issue