Skip to content

Commit

Permalink
Merge pull request #24 from dalvarez2596/lesson68
Browse files Browse the repository at this point in the history
Some styles improvement
  • Loading branch information
dalvarez2596 authored Oct 30, 2024
2 parents 4203a1a + c3661e4 commit c34d8f0
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def assign_default_role
if User.count == 1
self.add_role(:admin) if self.roles.blank?
self.add_role(:teacher)
self.add_role(:stuent)
self.add_role(:student)
else
self.add_role(:student) if self.roles.blank?
self.add_role(:teacher) # to allow any user to create own courses
Expand Down
2 changes: 1 addition & 1 deletion app/views/courses/_course.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.text-center
= number_to_currency(course.price)
.card-footer
.fa.fa-book
.fa.fa-list-check
= course.lessons.count
.card-footer
.row
Expand Down
4 changes: 3 additions & 1 deletion app/views/courses/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.card
.card-header
%h1 Editing course
%h3
.fa.fa-graduation-cap
Editing course
.card-body
= render 'form'
.card-footer
Expand Down
4 changes: 3 additions & 1 deletion app/views/courses/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.card
.card-header
%h1 New course
%h3
.fa.fa-graduation-cap
New course
.card-body
= render 'form'
.card-footer
Expand Down
3 changes: 2 additions & 1 deletion app/views/lessons/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
= f.label :content
= f.rich_text_area :content
%small= f.error :content, class: "text-danger"
%p
-# como estaba
-# = f.association :course
-# Esto de abajo asigno el input del html por defecto si ya es un lesson o por params. as: :hidden hide the input
-# = f.input :course_id, input_html: {value: @course.id || params[:course_id]}, as: :hidden
.form-actions
= f.button :submit, {class: "btn btn-success mb-2 mt-2"}
= f.button :submit, {class: "btn btn-success"}
2 changes: 1 addition & 1 deletion app/views/lessons/_lesson.html.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.card
.card-header
.far.fa-check-square
= link_to lesson.title, [@course, lesson]
- if policy(lesson).show?
.card-body
= lesson.content
= lesson.course
- if policy(lesson).edit?
.card-footer
= link_to 'Edit', edit_course_lesson_path(@course, lesson), class: 'btn btn-sm btn-warning'
Expand Down
13 changes: 12 additions & 1 deletion app/views/lessons/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
= link_to 'Courses', courses_path
\/
= link_to @lesson.course.title, course_path(@course)
\/
= link_to @lesson.title, course_lesson_path(@course, @lesson)
\/
edit
%p

.card
.card-header
%h1 Editing lesson
%h3
.far.fa-check-square
Editing lesson
.card-body
= render 'form'
.card-footer
Expand Down
11 changes: 10 additions & 1 deletion app/views/lessons/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
= link_to 'Courses', courses_path
\/
= link_to @course.title, course_path(@course)
\/
new
%p

.card
.card-header
%h1 New lesson
%h3
.far.fa-check-square
New lesson
.card-body
= render 'form'
.card-footer
Expand Down
1 change: 1 addition & 0 deletions app/views/lessons/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
= link_to @lesson.course.title, course_path(@course)
\/
= link_to @lesson.title, course_lesson_path(@course, @lesson)
%p

= render 'lessons/lesson', lesson: @lesson

Expand Down
17 changes: 13 additions & 4 deletions app/views/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
.badge.bg-info
= @users.count

.row.row-cols-lg-4
- @users.each do |user|
.col
= render 'users/user', user: user
-# .row.row-cols-lg-4
-# - @users.each do |user|
-# .col
-# = render 'users/user', user: user
%form.row.align-items-center.my-3
= search_form_for @q do |f|
Expand All @@ -31,6 +31,8 @@
%th= 'last_sign_in_at'.humanize
%th= 'current_sign_in_ip'.humanize
%th= 'last_sign_in_ip'.humanize
%th Confirmed?
%th Roles
%tbody
- @users.each do |user|
%tr
Expand All @@ -42,4 +44,11 @@
%td= user.last_sign_in_at
%td= user.current_sign_in_ip
%td= user.last_sign_in_ip
%td= user.confirmed?
%td
- user.roles.each do |role|
.badge.bg-info
= role.name
- if policy(user).edit?
= link_to 'Edit roles', edit_user_path(user), class: 'btn btn-sm btn-warning'

2 changes: 0 additions & 2 deletions app/views/users/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
= link_to 'Users', users_path

= render 'users/user', user: @user
8 changes: 8 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# User.create!(email: 'admin@admin.com', password: 'Password1234', password_confirmation: 'Password1234')
# this way we dont sent the confirmation email with devise
# user = User.new(
# email: 'admin@example.com',
# password: 'admin@example.com',
# password_confirmation: 'admin@example.com'
# )
# user.skip_confirmation!
# user.save!

30.times do
Course.create!([ {
Expand Down

0 comments on commit c34d8f0

Please sign in to comment.