From b3063a3238375cba43898af635a1842460fa648c Mon Sep 17 00:00:00 2001 From: Torsten Date: Thu, 12 Oct 2023 13:20:48 +0300 Subject: [PATCH] event list for teacher page --- Gemfile | 2 +- Gemfile.lock | 2 +- app/controllers/profiles_controller.rb | 3 +++ app/views/profiles/_profile.haml | 3 ++- app/views/profiles/show.html.haml | 22 ++++++++++++++++++++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 362e134..33642fd 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ gem "net-imap" gem "simple_form" , "5.1.0" gem "simple_form_tailwind_css" -gem "passenger" , require: "phusion_passenger/rack_handler" +gem "passenger" , "6.0.15" , require: "phusion_passenger/rack_handler" gem "bootsnap", require: false group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 0657f42..e19ae06 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -464,7 +464,7 @@ DEPENDENCIES mina net-imap newrelic_rpm - passenger + passenger (= 6.0.15) pg (~> 1.1) pundit rails (~> 7.0) diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 2efe0e6..127b21f 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -8,6 +8,9 @@ class ProfilesController < ApplicationController end def show + @events = Event.where(profile_id: @profile.id). + where("start_date > ? " , Date.today - 3.days). + order(:start_date) end def new diff --git a/app/views/profiles/_profile.haml b/app/views/profiles/_profile.haml index f7ad497..6971b92 100644 --- a/app/views/profiles/_profile.haml +++ b/app/views/profiles/_profile.haml @@ -6,7 +6,8 @@ .flex.mt-6.py-4.flex-col.max-w-screen-lg.overflow-hidden.bg-white.border.rounded.shadow-sm.lg:flex-row.sm:mx-auto .relative{:class => "lg:w-1/2"} -if profile.picture_url - = image_tag profile.picture_url, class: "object-cover w-full lg:absolute h-80 lg:h-full" + = link_to profile do + = image_tag profile.picture_url, class: "object-cover w-full lg:absolute h-80 lg:h-full" .flex.flex-col.justify-center.p-8.lg:p-16.lg:pl-10{:class => "lg:w-1/2"} %h5.mb-3.text-3xl.font-extrabold.leading-none.sm:text-4xl = profile.name diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index af96b88..175095a 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -1 +1,23 @@ = render "profile" , profile: @profile , header: "#{@profile.Kind} profile" + +.px-4 + .flex.justify-center + .px-4.py-4.text-center + %h1.text-2xl.font-bold.tracking-tight.sm:text-4xl + Upcoming events +-@events.each do |event| + %section.overflow-hidden.grid.grid-cols-1.m-5.md:m-12.lg:m-20.md:grid-cols-2 + %div + = picture_for( event , "h-56 w-full object-cover sm:h-full") + .p-8.md:p-12.lg:px-16.lg:py-24 + .mx-auto.max-w-xl.text-center + %h2.text-2xl.font-bold.md:text-4xl + = event.name + %h4.text-xl.mt-10.md:text-2xl + = event.start_date + .mt-8{ prose_classes } + = markdown(event.text) + - unless event.info.blank? + = link_to event.info , target: :blank do + .mt-5.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400.bg-cyan-100.hover:bg-blue-300 + More info