lessons functionality
This commit is contained in:
parent
b30739c21a
commit
4d8a5138f2
|
|
@ -28,6 +28,7 @@ module Admin
|
|||
def create
|
||||
@lesson = Lesson.new(admin_lesson_params)
|
||||
@week = @lesson.week
|
||||
@lesson.course = @week.course
|
||||
params[:week_id] = @week.id
|
||||
respond_to do |format|
|
||||
if @lesson.save
|
||||
|
|
|
|||
|
|
@ -23,12 +23,8 @@ class Lesson < ApplicationRecord
|
|||
scope :name_desc, -> { order(name: :desc) }
|
||||
|
||||
# == Callbacks ============================================================
|
||||
before_create :b_create
|
||||
|
||||
# == Class Methods ========================================================
|
||||
|
||||
# == Instance Methods =====================================================
|
||||
def b_create
|
||||
self.course = week.course
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<%= form.label :video %>
|
||||
<%= f.select :video_id, options_for_select(Video.all.map{|s|[s.name, s.id]}) %>
|
||||
<%= form.select :video_id, options_for_select(Video.all.map{|s|[s.name, s.id]}, selected: @lesson.video_id), { include_blank: true }, { class: 'form-control' } %>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
|
||||
<h6 class="m-0 font-weight-bold text-primary"><%= t('lesson.list') %></h6>
|
||||
<%= link_to raw('<i class="fa fa-plus"></i> Dodaj Nowy Tydzien'), new_admin_lesson_path(week_id: @week.id), { remote: true, class: 'btn btn-sm btn-primary float-right' } %>
|
||||
<%= link_to raw("<i class=\"fa fa-plus\"></i> #{t('lesson.add_new')}"), new_admin_lesson_path(week_id: @week.id), { remote: true, class: 'btn btn-sm btn-primary float-right' } %>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="ajax_form"></div>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<h1 class="h3 mb-1 text-gray-800"><%= t('course.title_show') %>: <strong><%= @course.name %></strong></h1>
|
||||
<h1 class="h3 mb-1 text-gray-800"><%= t('week.title_show') %>: <strong><%= @week.name %></strong> (<%= link_to raw(t('back')), admin_course_path(@course) %>)</h1>
|
||||
<p class="mb-4"><%= @week.description %></p>
|
||||
<%= render partial: '/admin/lessons/partials/index' %>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ pl:
|
|||
name: 'Nazwa'
|
||||
description: 'Opis'
|
||||
course: 'Kurs'
|
||||
video: Plik Wideo
|
||||
week: 'Tydzień'
|
||||
informations: 'Dodatkowe Informacje'
|
||||
file: 'Plik'
|
||||
|
|
|
|||
Loading…
Reference in New Issue