lessons functionality
This commit is contained in:
parent
b30739c21a
commit
4d8a5138f2
|
|
@ -28,6 +28,7 @@ module Admin
|
||||||
def create
|
def create
|
||||||
@lesson = Lesson.new(admin_lesson_params)
|
@lesson = Lesson.new(admin_lesson_params)
|
||||||
@week = @lesson.week
|
@week = @lesson.week
|
||||||
|
@lesson.course = @week.course
|
||||||
params[:week_id] = @week.id
|
params[:week_id] = @week.id
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @lesson.save
|
if @lesson.save
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,8 @@ class Lesson < ApplicationRecord
|
||||||
scope :name_desc, -> { order(name: :desc) }
|
scope :name_desc, -> { order(name: :desc) }
|
||||||
|
|
||||||
# == Callbacks ============================================================
|
# == Callbacks ============================================================
|
||||||
before_create :b_create
|
|
||||||
|
|
||||||
# == Class Methods ========================================================
|
# == Class Methods ========================================================
|
||||||
|
|
||||||
# == Instance Methods =====================================================
|
# == Instance Methods =====================================================
|
||||||
def b_create
|
|
||||||
self.course = week.course
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<%= form.label :video %>
|
<%= 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>
|
||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="card shadow mb-4">
|
<div class="card shadow mb-4">
|
||||||
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
|
<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>
|
<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>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div id="ajax_form"></div>
|
<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('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>
|
<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>
|
<p class="mb-4"><%= @week.description %></p>
|
||||||
|
<%= render partial: '/admin/lessons/partials/index' %>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ pl:
|
||||||
name: 'Nazwa'
|
name: 'Nazwa'
|
||||||
description: 'Opis'
|
description: 'Opis'
|
||||||
course: 'Kurs'
|
course: 'Kurs'
|
||||||
|
video: Plik Wideo
|
||||||
week: 'Tydzień'
|
week: 'Tydzień'
|
||||||
informations: 'Dodatkowe Informacje'
|
informations: 'Dodatkowe Informacje'
|
||||||
file: 'Plik'
|
file: 'Plik'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue