Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some styling to the current courses and enrollments #41

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/helpers/courses_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ def review_button(course)
if current_user
if user_course.any?
if user_course.pending_review.any?
link_to "Add a review", edit_enrollment_path(user_course.first)
link_to edit_enrollment_path(user_course.first) do
"<i class='text-warning fa fa-star'></i>".html_safe + "" +
"<i class='text-dark fa fa-question'></i>".html_safe + "" +
"Add a review"
end
else
link_to "Thanks for reviewing! Your Review", enrollment_path(user_course.first)
link_to enrollment_path(user_course.first) do
"<i class='text-warning fa fa-star'></i>".html_safe + "" +
"<i class='text-dark fa fa-check'></i>".html_safe + "" +
"Thanks for reviewing! Your Review"
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/course.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Course < ApplicationRecord
validates :title, :short_description, :language, :price, :level, presence: true
validates :description, presence: true, length: { minimum: 5 }

validates :title, uniqueness: true
belongs_to :user, counter_cache: true
# User.find_each{ |user| User.reset_counters(user.id, :courses)}

Expand Down
50 changes: 29 additions & 21 deletions app/views/courses/_course.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,45 @@
= enrollment_button(course)
.row
= review_button(course)
.card-footer
.text-warning.fa.fa-star
%b= course.average_rating
-# Enrollments count:
-# = course.enrollments.count
-# Counter cache enrollments count:
(
.fa.fa-user-graduate
= course.enrollments_count
)
.card-footer
.fa.fa-list-check
= course.lessons_count
.card-footer
.row
.col-md-6
.fa.fa-globe-africa
= course.language
.text-warning.fa.fa-star
%b= course.average_rating
-# Enrollments count:
-# = course.enrollments.count
-# Counter cache enrollments count:
(
.fa.fa-user-graduate
= course.enrollments_count
)
.fa.fa-list-check
= course.lessons_count
.col-md-6
.text-end
.fa.fa-signal
= course.level
.fa.fa-chalkboard-teacher
= link_to course.user.username, user_path(course.user)
-# .card-footer
-# .fa.fa-list-check
-# = course.lessons_count
.card-footer
.row
.col-md-6
.fa.fa-clock
= course.created_at.strftime('%d-%b-%Y')
.fa.fa-globe-africa
= course.language
.col-md-6
.text-end
.fa.fa-chalkboard-teacher
= link_to course.user.username, user_path(course.user)
.fa.fa-signal
= course.level
-# .card-footer
-# .row
-# .col-md-6
-# .fa.fa-clock
-# = course.created_at.strftime('%d-%b-%Y')
-# .col-md-6
-# .text-end
-# .fa.fa-chalkboard-teacher
-# = link_to course.user.username, user_path(course.user)
- if current_user && policy(course).edit?
.card-footer
= link_to 'Edit', edit_course_path(course), class: 'btn btn-sm btn-warning'
Expand Down
6 changes: 4 additions & 2 deletions app/views/courses/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
- content_for :title do
E-learning
\|
All Courses
= action_name.humanize
courses

%h3.text-center
Courses
= action_name.humanize
courses
.badge.bg-info
= @courses.count

Expand Down
8 changes: 5 additions & 3 deletions app/views/enrollments/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
-content_for :title do
E-learning
\|
All Enrollments
= action_name.humanize
enrollments

%h3.text-center
Enrollments
%h3.text-center
= action_name.humanize
enrollments
.badge.bg-info
= @enrollments.count
%p
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
New Course
= link_to created_courses_path, class: "dropdown-item" do
.fa.fa-graduation-cap
My Courses
Created Courses
.badge.bg-danger
= current_user.courses_count
= link_to my_students_enrollments_path, class: "dropdown-item" do
Expand Down
Loading