clean up profile generation (wip)
This commit is contained in:
@ -13,7 +13,7 @@ class EventsController < ApplicationController
|
|||||||
# GET /events/new
|
# GET /events/new
|
||||||
def new
|
def new
|
||||||
kind = params[:profile]
|
kind = params[:profile]
|
||||||
kind = Profile.types.first unless Profile.types.include?(kind)
|
kind = Profile.kinds.first unless Profile.kinds.include?(kind)
|
||||||
profile = current_member.profile(kind)
|
profile = current_member.profile(kind)
|
||||||
if(profile)
|
if(profile)
|
||||||
@event = Event.new profile: profile
|
@event = Event.new profile: profile
|
||||||
|
@ -13,7 +13,7 @@ class ProfilesController < ApplicationController
|
|||||||
# GET /profiles/new
|
# GET /profiles/new
|
||||||
def new
|
def new
|
||||||
kind = params[:kind]
|
kind = params[:kind]
|
||||||
kind = Profile.types.first unless Profile.types.include?(kind)
|
kind = Profile.kinds.first unless Profile.kinds.include?(kind)
|
||||||
@profile = Profile.new kind: kind
|
@profile = Profile.new kind: kind
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ class Member < ApplicationRecord
|
|||||||
has_many :entities
|
has_many :entities
|
||||||
has_many :profiles
|
has_many :profiles
|
||||||
|
|
||||||
Profile.types.each do |kind|
|
Profile.kinds.each do |kind|
|
||||||
define_method :kind do
|
define_method :"#{kind}_profile" do
|
||||||
Profile.where( member_id: self.id).where(kind: kind).first
|
Profile.where( member_id: self.id).where(kind: kind).first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
class Profile < ApplicationRecord
|
class Profile < ApplicationRecord
|
||||||
belongs_to :member
|
belongs_to :member
|
||||||
has_many :events
|
has_many :events
|
||||||
|
|
||||||
validates :name , presence: true
|
validates :name , presence: true
|
||||||
validates :kind , presence: true
|
validates :kind , presence: true
|
||||||
validates :bio , presence: true
|
validates :bio , presence: true
|
||||||
@ -9,7 +9,7 @@ class Profile < ApplicationRecord
|
|||||||
|
|
||||||
mount_uploader :picture, PictureUploader
|
mount_uploader :picture, PictureUploader
|
||||||
|
|
||||||
def self.types
|
def self.kinds
|
||||||
["member" , "artist" , "teacher"]
|
["member" , "artist" , "teacher"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
0
app/views/members/_artist_profile.haml
Normal file
0
app/views/members/_artist_profile.haml
Normal file
24
app/views/members/_member_profile.haml
Normal file
24
app/views/members/_member_profile.haml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
.flex.flex-col.justify-center
|
||||||
|
=link_to profile_path(profile) do
|
||||||
|
.px-4.py-4.text-center.bg-gray-200
|
||||||
|
%h1.text-2xl.font-bold.tracking-tight.sm:text-4xl
|
||||||
|
Member Profile
|
||||||
|
.flex.mt-6.py-4.flex-col.max-w-screen-lg.overflow-hidden.bg-white.border.rounded.shadow-sm
|
||||||
|
.relative
|
||||||
|
-if profile.picture_url
|
||||||
|
= image_tag profile.picture_url, class: "object-cover w-full h-60"
|
||||||
|
-else
|
||||||
|
No picture
|
||||||
|
%h5.m-4.text-3xl.font-bold.text-center
|
||||||
|
= profile.name
|
||||||
|
.mb-8.text-gray-800.text-center
|
||||||
|
.prose= markdown(profile.bio)
|
||||||
|
|
||||||
|
|
||||||
|
.flex.justify-between
|
||||||
|
= link_to edit_profile_path(profile) do
|
||||||
|
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||||
|
Edit
|
||||||
|
= form_tag( profile_path(profile.id) , {method: :delete } ) do
|
||||||
|
%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
|
10
app/views/members/_teacher_profile.haml
Normal file
10
app/views/members/_teacher_profile.haml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
-if event = profile.events.length >0
|
||||||
|
%div
|
||||||
|
=link_to profile.events.first.name , event_path(profile.events.first) , class: "underline"
|
||||||
|
= 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
|
||||||
|
-else
|
||||||
|
= 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 #{profile.Kind} Event
|
@ -4,57 +4,43 @@
|
|||||||
%h1.text-2xl.font-bold.tracking-tight.sm:text-4xl
|
%h1.text-2xl.font-bold.tracking-tight.sm:text-4xl
|
||||||
Settings and profiles
|
Settings and profiles
|
||||||
%h4.text-xl.mt-4.md:text-2xl
|
%h4.text-xl.mt-4.md:text-2xl
|
||||||
Allowing you to create and edit various profiles
|
View and edit your profiles, and change settings
|
||||||
.mt-4.text-lg.pt-4
|
|
||||||
You can have seperate profiles as teacher, artist, or coop member.
|
|
||||||
If you choose to create them they will be publicly listed.
|
|
||||||
Techers and Artists may then create events.
|
|
||||||
|
|
||||||
.grid.grid-cols-2.mx-20
|
.grid.grid-cols-1.mx-8.gap-8.md:grid-cols-2.mx-12.gap-12.lg:grid-cols-3.mx-16.gap-16
|
||||||
.first
|
.flex.flex-col.justify-between
|
||||||
- Profile.types.each do |kind|
|
%h3.text-2xl.bg-gray-200.p-4.text-center Settings
|
||||||
.grid.grid-cols-4
|
.flex.justify-beteen.flex-wrap
|
||||||
- if profile = @member.profile(kind)
|
= form_tag( destroy_member_session_path , {method: :delete } ) do
|
||||||
%div
|
%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}
|
||||||
=profile.Kind
|
Sign out
|
||||||
=link_to profile.name , profile_path(profile) , class: "underline"
|
= link_to edit_member_registration_path do
|
||||||
exists
|
%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}
|
||||||
= link_to edit_profile_path(profile) do
|
Change Password
|
||||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
= link_to members_edit_email_path do
|
||||||
Edit
|
%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}
|
||||||
= link_to new_event_path(profile: profile.kind) do
|
Change Email
|
||||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
.grid.grid-cols-6.gap-4.mt-10.mx-10
|
||||||
New #{profile.Kind} Event
|
-@member.entities.each do |entity|
|
||||||
-if event = profile.events.length >0
|
%div= entity.type
|
||||||
%div
|
%div= entity.name
|
||||||
=link_to profile.events.first.name , event_path(profile.events.first) , class: "underline"
|
%div= entity.value
|
||||||
= link_to edit_event_path(profile.events.first) do
|
%div
|
||||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
If you are an artist click
|
||||||
Edit
|
=link_to "here" , new_profile_path(kind: :artist) , class: "underline"
|
||||||
-else
|
%br
|
||||||
No events
|
Or a teacher, click
|
||||||
-else
|
=link_to "here" , new_profile_path(kind: :teacher) , class: "underline"
|
||||||
%div Create new profile as
|
|
||||||
= link_to new_profile_path(kind: kind) do
|
|
||||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
|
||||||
= kind.capitalize
|
|
||||||
%div Create profile first
|
|
||||||
%div No events, create profile first
|
|
||||||
|
|
||||||
.grid.grid-cols-6.gap-4.mt-10.mx-10
|
- unless @member.member_profile
|
||||||
-@member.entities.each do |entity|
|
%div
|
||||||
%div= entity.type
|
%h3.text-2xl.bg-gray-200.p-4.text-center No Profile
|
||||||
%div= entity.name
|
%h2 Create new
|
||||||
%div= entity.value
|
= link_to new_profile_path(kind: :member) do
|
||||||
|
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||||
|
Member profile
|
||||||
|
.prose
|
||||||
|
Member profiles are always public and contain an image and text.
|
||||||
|
|
||||||
.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-3
|
- Profile.kinds.each do |kind|
|
||||||
.flex.justify-beteen
|
- if profile = @member.profile(kind)
|
||||||
= form_tag( destroy_member_session_path , {method: :delete } ) do
|
%div= render "#{kind}_profile" , profile: profile
|
||||||
%button.mt-10.ml-10.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
|
|
||||||
= link_to edit_member_registration_path do
|
|
||||||
%button.mt-10.ml-10.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400{type: :submit}
|
|
||||||
Change Password
|
|
||||||
= link_to members_edit_email_path do
|
|
||||||
%button.mt-10.ml-10.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
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.flex.justify-center
|
.flex.justify-center
|
||||||
.column
|
.column.max-w-lg
|
||||||
.text-xl.m-4
|
.text-xl.m-4
|
||||||
Edit your
|
Edit your
|
||||||
=@profile.Kind
|
=@profile.Kind
|
||||||
|
Reference in New Issue
Block a user