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