improve events
This commit is contained in:
parent
d2eaacaaad
commit
15ccc5eedb
|
@ -2,7 +2,7 @@ class EventsController < ApplicationController
|
|||
before_action :set_event, only: %i[ show edit update destroy ]
|
||||
|
||||
def index
|
||||
@events = Event.all
|
||||
@events = Event.where("start_date > ? " , Date.today - 3.days)
|
||||
end
|
||||
|
||||
def show
|
||||
|
@ -55,6 +55,6 @@ class EventsController < ApplicationController
|
|||
# Only allow a list of trusted parameters through.
|
||||
def event_params
|
||||
params.require(:event).permit(:name, :text, :start_date, :end_date,
|
||||
:profile_id, :picture, :picture_cache)
|
||||
:profile_id, :picture, :picture_cache , :info)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
class ProfilesController < ApplicationController
|
||||
before_action :set_profile, only: %i[ show edit update destroy ]
|
||||
|
||||
def index
|
||||
@profiles = Profile.page params[:page]
|
||||
def teachers
|
||||
@profiles = Profile.where(kind: :teacher).page( 1 ).per(50)
|
||||
@header = "Meet Hub Feenix teachers and organizers"
|
||||
render :index
|
||||
end
|
||||
|
||||
def show
|
||||
|
@ -52,6 +54,7 @@ class ProfilesController < ApplicationController
|
|||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def profile_params
|
||||
params.require(:profile).permit(:name, :bio, :picture,:picture_cache, :kind)
|
||||
params.require(:profile).permit(:name, :bio, :picture,:picture_cache,
|
||||
:kind , :info)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,9 @@ module ApplicationHelper
|
|||
"#{text[0..to]} . . . ".html_safe
|
||||
end
|
||||
|
||||
def small_date(date)
|
||||
date.strftime("%-d.%-m")
|
||||
end
|
||||
|
||||
def main_app
|
||||
Rails.application.routes.url_helpers
|
||||
|
|
|
@ -14,10 +14,21 @@ class Member < ApplicationRecord
|
|||
Profile.where( member_id: self.id).where(kind: kind).first
|
||||
end
|
||||
end
|
||||
|
||||
def profile( kind )
|
||||
Profile.where( member_id: self.id).where(kind: kind).first
|
||||
end
|
||||
|
||||
def teacher
|
||||
profile( :teacher )
|
||||
end
|
||||
|
||||
def future_events
|
||||
teacher = profile( :teacher )
|
||||
return [] unless teacher
|
||||
teacher.future_events
|
||||
end
|
||||
|
||||
def admin?
|
||||
email == "torsten@villataika.fi"
|
||||
end
|
||||
|
|
|
@ -16,4 +16,8 @@ class Profile < ApplicationRecord
|
|||
def Kind
|
||||
self.kind.capitalize
|
||||
end
|
||||
|
||||
def future_events
|
||||
self.events.where( "start_date > ?" , Date.today)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,3 +9,7 @@
|
|||
= 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
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
.fex.flex-col.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm.m-10
|
||||
=link_to event do
|
||||
= image_for( event , class: "h-60 w-full object-cover")
|
||||
%div
|
||||
%h3.pt-5.text-2xl.bg-gray-100.text-black.font-bold.text-center
|
||||
= event.name
|
||||
.py-1.text-xl.bg-gray-100.text-black.font-bold.text-center
|
||||
= small_date(event.start_date) + " - " + small_date(event.end_date)
|
||||
%div.h-full
|
||||
.p-5.text-center
|
||||
.m-2.text-sm.leading-relaxed.line-clamp-3{ prose_classes }
|
||||
= shorten markdown(event.text)
|
|
@ -2,6 +2,7 @@
|
|||
= f.error_notification
|
||||
|
||||
= f.input :name
|
||||
= f.input :info , label: "Link to event"
|
||||
= render "merged/form/editor" , object: @event , field: :text, form: f
|
||||
.grid.grid-cols-2.gap-10
|
||||
= f.input :start_date
|
||||
|
@ -13,6 +14,7 @@
|
|||
label: (@event.picture.blank? ? "Add picture" : "Change picture")
|
||||
= f.hidden_field :picture_cache
|
||||
|
||||
|
||||
.flex.justify-between
|
||||
%button.mt-6.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||
= f.submit 'Save'
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
.flex.justify-center
|
||||
.grid.grid-cols-4
|
||||
.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-4
|
||||
- @events.each do |event|
|
||||
.fex.flex-col.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm.m-10
|
||||
=link_to event do
|
||||
= image_for( event , class: "h-60 w-full object-cover")
|
||||
%h3.py-5.text-2xl.bg-gray-100.text-black.font-bold.text-center
|
||||
= event.name
|
||||
%div.h-full
|
||||
.p-5.text-center
|
||||
.m-2.text-sm.leading-relaxed.line-clamp-3{ prose_classes }
|
||||
= shorten markdown(event.text)
|
||||
= render "event_small" , event: event
|
||||
|
|
|
@ -51,6 +51,16 @@
|
|||
%li.border-white.border-x.py-2.px-4.hover:bg-gray-50.hover:border-gray-700
|
||||
%a.text-gray-700.transition.hover:opacity-75{:href => "/coworking"}
|
||||
Coworking
|
||||
|
||||
%p.mt-5.font-medium.text-gray-900 Events
|
||||
%nav.mt-2{"aria-label" => "Footer Navigation - Hub Feenix"}
|
||||
%ul.space-y-2.text-sm
|
||||
%li.border-white.border-x.py-2.px-4.hover:bg-gray-50.hover:border-gray-700
|
||||
%a.text-gray-700.transition.hover:opacity-75{:href => "/events"}
|
||||
Upcoming events
|
||||
%li.border-white.border-x.py-2.px-4.hover:bg-gray-50.hover:border-gray-700
|
||||
%a.text-gray-700.transition.hover:opacity-75{:href => "/teachers"}
|
||||
Teachers
|
||||
.col-span-2.sm:col-span-1
|
||||
%p.font-medium.text-gray-900 News
|
||||
%nav.mt-6{"aria-label" => "Footer Navigation - Downloads"}
|
||||
|
|
|
@ -9,21 +9,6 @@
|
|||
%button.bg-red-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400{type: :submit}
|
||||
Delete Profile
|
||||
|
||||
.flex.flex-col.justify-center
|
||||
=link_to profile_path(profile) do
|
||||
.my-2.px-2.py-2.text-center.bg-gray-200
|
||||
%h1.text-xl.font-bold.tracking-tight.sm:text-4xl
|
||||
Your Events
|
||||
-if event = profile.events.length >0
|
||||
%div
|
||||
Your last Event:
|
||||
= profile.events.first.name
|
||||
=link_to event_path(profile.events.first) do
|
||||
%button.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||
View
|
||||
= link_to edit_event_path(profile.events.first) do
|
||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||
Edit
|
||||
= link_to new_event_path(profile: profile.kind) do
|
||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||
New Event
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
= paginate @members
|
||||
.flex.justify-center
|
||||
|
||||
.grid.grid-cols-4
|
||||
.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-4
|
||||
- @members.each do |member|
|
||||
.fex.flex-col.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm.m-10
|
||||
=link_to member do
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
Settings and profiles
|
||||
%h4.text-xl.mt-4.md:text-2xl
|
||||
View and edit your profiles, and change settings
|
||||
.grid.grid-cols-1.mx-8.gap-8.md:grid-cols-2.mx-12.gap-12.lg:grid-cols-3.mx-16.gap-16
|
||||
.grid.grid-cols-1.mx-8.gap-8.md:grid-cols-2.mx-12.gap-12.lg:grid-cols-4.mx-16.gap-16
|
||||
.flex.flex-col.justify-between
|
||||
%h3.text-2xl.bg-gray-200.p-4.text-center Settings
|
||||
.flex.justify-beteen.flex-wrap
|
||||
.flex.justify-center.flex-col
|
||||
= form_tag( destroy_member_session_path , {method: :delete } ) do
|
||||
%button.m-4.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400{type: :submit}
|
||||
Sign out
|
||||
|
@ -18,7 +18,7 @@
|
|||
= link_to members_edit_email_path do
|
||||
%button.m-4.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400{type: :submit}
|
||||
Change Email
|
||||
.grid.grid-cols-6.gap-4.mt-10.mx-10
|
||||
.grid.grid-cols-3.gap-4.mt-10.mx-10
|
||||
-@member.entities.each do |entity|
|
||||
%div= entity.type
|
||||
%div= entity.name
|
||||
|
@ -44,3 +44,14 @@
|
|||
- Profile.kinds.each do |kind|
|
||||
- if profile = @member.profile(kind)
|
||||
%div= render "#{kind}_profile" , profile: profile
|
||||
|
||||
-if (events = @member.future_events).length > 0
|
||||
- events.each do |event|
|
||||
%div
|
||||
= render "events/event_small" , event: event
|
||||
=link_to event_path(event) do
|
||||
%button.ml-10.mr-5.inline-block.rounded-lg.px-4.py-2.text-md.font-medium.border.border-gray-400
|
||||
View
|
||||
= link_to edit_event_path(event) do
|
||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-2.text-md.font-medium.border.border-gray-400
|
||||
Edit
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
= f.error_notification
|
||||
|
||||
= f.input :name
|
||||
= f.input :info , label: "Link to Homapage"
|
||||
= render "merged/form/editor" , object: @profile , field: :bio, form: f
|
||||
= f.input :kind, :as => :hidden
|
||||
.flex.h-16.mt-2
|
||||
|
|
|
@ -12,3 +12,7 @@
|
|||
= profile.name
|
||||
.mb-8.text-gray-800
|
||||
.prose= markdown(profile.bio)
|
||||
- unless profile.info.blank?
|
||||
= link_to profile.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
|
||||
Homepage
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
= paginate @profiles
|
||||
.flex.justify-center
|
||||
|
||||
.grid.grid-cols-4
|
||||
- @profiles.each do |profile|
|
||||
.fex.flex-col.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm.m-10
|
||||
=link_to profile do
|
||||
= image_for( profile , class: "h-60 w-full object-cover")
|
||||
%h3.py-5.text-2xl.bg-gray-100.text-black.font-bold.text-center
|
||||
= profile.name
|
||||
%div.h-full
|
||||
.p-5.text-center
|
||||
.m-2.text-sm.leading-relaxed.line-clamp-3{ prose_classes }
|
||||
= shorten markdown(profile.bio)
|
||||
.flex.justify-center
|
||||
%h3.text-3xl.font-bold= @header
|
||||
.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-4.gap-10.m-10
|
||||
- @profiles.each do |profile|
|
||||
.fex.flex-col.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm
|
||||
=link_to profile do
|
||||
= image_for( profile , class: "h-60 w-full object-cover")
|
||||
%h3.py-5.text-2xl.bg-gray-100.text-black.font-bold.text-center
|
||||
= profile.name
|
||||
%div.h-full
|
||||
.p-5.text-center
|
||||
.m-2.text-sm.leading-relaxed.line-clamp-3{ prose_classes }
|
||||
= shorten markdown(profile.bio)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
resources :events
|
||||
resources :profiles
|
||||
resources :profiles, except: :index
|
||||
resources :entities
|
||||
get "/teachers" , to: "profiles#teachers"
|
||||
|
||||
devise_for :members ,controllers: { registrations: 'registrations' }
|
||||
devise_scope :member do
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddInfoToEvents < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :events, :info, :string
|
||||
add_column :profiles, :info, :string
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_01_16_120518) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_06_11_105046) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
@ -33,6 +33,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_16_120518) do
|
|||
t.string "picture", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "info"
|
||||
t.index ["profile_id"], name: "index_events_on_profile_id"
|
||||
end
|
||||
|
||||
|
@ -72,6 +73,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_16_120518) do
|
|||
t.bigint "member_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "info"
|
||||
t.index ["member_id"], name: "index_profiles_on_member_id"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue