Skip to content

Commit

Permalink
Merge pull request #35 from dalvarez2596/lesson-80
Browse files Browse the repository at this point in the history
Change some styles in navigation
  • Loading branch information
dalvarez2596 authored Nov 7, 2024
2 parents c577a4a + c3c628c commit b1fa072
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 24 deletions.
3 changes: 3 additions & 0 deletions app/models/enrollment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class Enrollment < ApplicationRecord
validates :user, :course, presence: true
# User cant be subscribed to the same course twice

validates_presence_of :rating, if: :review?
validates_presence_of :review, if: :rating?

validates_uniqueness_of :user_id, scope: :course_id
validates_uniqueness_of :course_id, scope: :user_id

Expand Down
82 changes: 59 additions & 23 deletions app/views/layouts/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,73 @@
= link_to courses_path, class: "nav-link" do
.fa.fa-graduation-cap
Courses
%li.nav-item{class: "#{'fw-bold' if current_page?(new_course_path)}"}
= link_to new_course_path, class: "nav-link" do
.fa.fa-plus
New Course
%li.nav-item{class: "#{'fw-bold' if current_page?(users_path)}"}
= link_to users_path, class: "nav-link" do
.fa.fa-users
Users
%li.nav-item{class: "#{'fw-bold' if current_page?(enrollments_path)}"}
= link_to enrollments_path, class: "nav-link" do
.fa.fa-lock-open
Enrollments

.form-inline.align-self-center
= search_form_for @ransack_courses, as: :courses_search, url: courses_path do |f|
.input-group.input-group-sm
= f.search_field :title_cont, class: "form-control-sm", placeholder: "Find a course", :autocomplete => :off
%button.btn.btn-primary{:type => "submit"}
%span.fa.fa-search{"aria-hidden" => "true"}

.form-inline.align-self-center
= search_form_for @ransack_courses, as: :courses_search, url: courses_path do |f|
.input-group.input-group-sm
= f.search_field :title_cont, class: "form-control-sm", placeholder: "Find a course", :autocomplete => :off
%button.btn.btn-primary{:type => "submit"}
%span.fa.fa-search{"aria-hidden" => "true"}
-# %li.nav-item{class: "#{'fw-bold' if current_page?(new_course_path)}"}
-# = link_to new_course_path, class: "nav-link" do
-# .fa.fa-plus
-# New Course
-# %li.nav-item{class: "#{'fw-bold' if current_page?(users_path)}"}
-# = link_to users_path, class: "nav-link" do
-# .fa.fa-users
-# Users
-# %li.nav-item{class: "#{'fw-bold' if current_page?(enrollments_path)}"}
-# = link_to enrollments_path, class: "nav-link" do
-# .fa.fa-lock-open
-# Enrollments

%ul.navbar-nav.me-auto
- if current_user.has_role?(:student)
%li.nav-item.dropdown
%a#studentDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "data-bs-toggle" => "dropdown", :href => "#", :role => "button"}
.fa.fa-graduation-cap
Learn
.dropdown-menu.dropdown-menu-right{"aria-labelledby" => "studentDropdown"}

- if current_user.has_role?(:teacher)
%li.nav-item.dropdown
%a#teacherDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "data-bs-toggle" => "dropdown", :href => "#", :role => "button"}
.fa.fa-chalkboard-teacher
Teacher
.dropdown-menu.dropdown-menu-right{"aria-labelledby" => "teacherDropdown"}
= link_to new_course_path, class: "dropdown-item" do
.fa.fa-graduation-cap
.fa.fa-plus
New Course

- if current_user.has_role?(:admin)
%li.nav-item.dropdown
%a#adminDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "data-bs-toggle" => "dropdown", :href => "#", :role => "button"}
.fa.fa-cog
Admin
.dropdown-menu.dropdown-menu-right{"aria-labelledby" => "adminDropdown"}
= link_to users_path, class: "dropdown-item" do
.fa.fa-users
Users
= link_to enrollments_path, class: "dropdown-item" do
.fa.fa-lock-open
Enrollments
= link_to activity_path, class: "dropdown-item" do
.fa.fa-bell
Activity


-# .form-inline.align-self-center
-# = form_tag(courses_path, method: :get) do
-# .input-group.input-group-sm
-# = text_field_tag :title, params[:title], autocomplete: "off", placeholder: "Search", class: "form-control"
-# %button.btn.btn-primary{:type => "submit"}
-# %span.fa.fa-search{"aria-hidden" => "true"}
%ul.navbar-nav.me-right
%li.nav-item{class: "#{'fw-bold' if current_page?(home_activity_path)}"}
= link_to home_activity_path, class: "nav-link" do
.fa.fa-bell
Activity
-# %li.nav-item{class: "#{'fw-bold' if current_page?(activity_path)}"}
-# = link_to activity_path, class: "nav-link" do
-# .fa.fa-bell
-# Activity
%li.nav-item.dropdown
%a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "data-bs-toggle" => "dropdown", :href => "#", :role => "button"}
%b= current_user
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end
resources :users, only: [ :index, :edit, :show, :update ]
get "home/index"
get "home/activity"
get "activity", to: "home#activity"
root "home#index"

# get "privacy_policy", to: "static_pages#privacy_policy"
Expand Down

0 comments on commit b1fa072

Please sign in to comment.