osem-fcy/app/views/admin/versions/_object_desc_and_link.html.haml

223 lines
8.1 KiB
Text
Raw Normal View History

:ruby
object = current_or_last_object_state(version.item_type, version.item_id)
2018-06-01 17:38:37 +03:00
unless version.item_type == 'Role' || version.item_type == 'UsersRole'
conference = Conference.find_by(id: version.conference_id)
conference_short_title = conference.try(:short_title) || current_or_last_object_state('Conference', version.conference_id).try(:short_title) || ' '
end
2016-08-18 01:28:40 +05:30
- case version.item_type
- when 'Organization'
organization
= link_to_organization(version.item_id)
2016-08-18 01:28:40 +05:30
- when 'UsersRole'
2018-06-01 17:38:37 +03:00
- role = current_or_last_object_state('Role', object.role_id)
- role_name = role.try(:name) || PaperTrail::Version.where(item_type: 'Role', item_id: object.role_id).last.changeset[:name].second
role
- if role_name == 'organization_admin'
- if Organization.find_by(id: version.conference_id)
-# organization_admin belongs to organization and not conferences
- organization = Organization.find_by(id: version.conference_id)
= link_if_alive version, role_name,
admins_admin_organization_path(organization), organization
- else
(Deleted Organization)
- else
- conference = Conference.find_by(id: version.conference_id)
- conference_short_title = conference.try(:short_title) || current_or_last_object_state('Conference', version.conference_id).try(:short_title) || ' '
2017-10-12 21:17:23 +05:30
= link_if_alive version, role.try(:name), admin_conference_role_path(conference_short_title,role.try(:name) || ' '), conference
= version.event == 'create' ? 'to' : 'from'
user
2018-06-01 17:38:37 +03:00
= link_to_user(object.user_id)
2016-08-18 01:28:40 +05:30
- when 'Subscription', 'Registration'
conference
= link_to_conference(version.conference_id)
2016-08-18 01:28:40 +05:30
- when 'Commercial'
2018-06-01 17:38:37 +03:00
- commercialable = current_or_last_object_state(object.commercialable_type, object.commercialable_id)
2018-06-01 17:38:37 +03:00
- case object.commercialable_type
- when 'Event'
commercial in event
- if commercialable && conference
= link_to commercialable.title,
admin_conference_program_event_path(conference, commercialable.id)
- else
= commercialable.title
= "with ID #{commercialable.id}"
- when 'Venue'
commercial in venue
- if commercialable && conference
= link_to commercialable.name,
edit_admin_conference_venue_path(conference_short_title,
commercialable.id, anchor: 'commercials-content')
- else
= commercialable.name
= "with ID #{commercialable.id}"
- when 'Conference'
commercial in conference
- if commercialable
= link_to commercialable.short_title,
admin_conference_commercials_path(commercialable.short_title)
- else
= commercialable.short_title
= "with ID #{commercialable.id}"
2016-08-18 01:28:40 +05:30
- when 'EventsRegistration', 'Comment', 'Vote', 'Event'
event
- event_id = object.try(:event_id) || object.try(:commentable_id) || object.id
= link_to (current_or_last_object_state('Event', event_id).try(:title) || 'deleted event'),
admin_conference_program_event_path(conference_short_title, event_id)
2016-08-18 01:28:40 +05:30
- when 'EventSchedule'
2016-08-18 00:32:16 +05:30
event
2018-06-01 17:38:37 +03:00
= link_to (current_or_last_object_state('Event', object.event_id).try(:title) || 'deleted'),
admin_conference_program_event_path(conference_short_title, object.event_id)
2016-08-18 00:32:16 +05:30
in
2019-03-05 23:28:57 +01:00
= link_to "Schedule #{version.item.schedule_id}",
admin_conference_schedule_path(conference_short_title, version.item.schedule_id)
2016-08-18 01:28:40 +05:30
- when 'Schedule'
= link_if_alive version, "Schedule #{version.item_id}",
admin_conference_schedule_path(conference_short_title, version.item_id),
conference
2016-08-18 01:28:40 +05:30
- when 'Conference'
conference
= link_to_conference(version.item_id)
2016-08-18 01:28:40 +05:30
- when 'RegistrationPeriod'
= link_if_alive version, 'registration period',
admin_conference_registration_period_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'Contact'
= link_if_alive version, 'contact details',
edit_admin_conference_contact_path(conference_short_title),
conference
2017-07-17 12:00:06 +03:00
- when 'Booth'
= t 'booth'
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.title,
admin_conference_booth_path(conference_id: Conference.find(version.conference_id).short_title, id: version.item_id ),
conference
2017-07-17 12:00:06 +03:00
2016-08-18 01:28:40 +05:30
- when 'Program'
= link_if_alive version, 'program',
admin_conference_program_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'Cfp'
cfp for
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.cfp_type,
admin_conference_program_cfp_path(conference_short_title, version.item_id),
conference
2016-08-18 01:28:40 +05:30
- when 'Track'
track
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.name,
admin_conference_program_track_path(conference_short_title, object.try(:short_name)),
conference
2016-08-18 01:28:40 +05:30
- when 'EventType'
event type
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.title,
admin_conference_program_event_types_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'Role'
role
2018-06-01 17:38:37 +03:00
- role_name = object.try(:name) || PaperTrail::Version.where(item_type: 'Role', item_id: version.item_id).last.changeset[:name].second
- if role_name == 'organization_admin'
- if Organization.find_by(id: version.conference_id)
-# organization_admin belongs to organization and not conferences
- organization = Organization.find_by(id: version.conference_id)
2018-04-07 16:24:58 +03:00
= link_if_alive version, role_name,
admins_admin_organization_path(organization), organization
- else
(Role Deleted)
- else
- conference = Conference.find_by(id: version.conference_id)
- conference_short_title = conference.try(:short_title) || current_or_last_object_state('Conference', version.conference_id).try(:short_title) || ' '
= link_if_alive version, role_name,
admin_conference_role_path(conference_short_title, role_name), conference
2016-08-18 01:28:40 +05:30
- when 'Venue'
venue
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.name,
admin_conference_venue_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'Lodging'
lodging
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.name,
admin_conference_lodgings_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'Room'
room
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.name,
admin_conference_venue_rooms_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'Sponsor'
sponsor
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.name,
admin_conference_sponsors_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'SponsorshipLevel'
sponsorship level
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.title,
admin_conference_sponsorship_levels_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'Ticket'
ticket
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.title,
admin_conference_ticket_path(conference_short_title, version.item_id),
conference
2016-08-18 01:28:40 +05:30
- when 'DifficultyLevel'
difficulty level
2018-06-01 17:38:37 +03:00
= link_if_alive version, object.title,admin_conference_program_difficulty_levels_path(conference_short_title), conference
2016-08-18 01:28:40 +05:30
- when 'Splashpage'
= link_if_alive version, 'splashpage',
admin_conference_splashpage_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'EmailSettings'
= link_if_alive version, 'email settings',
admin_conference_emails_path(conference_short_title),
conference
2016-08-18 01:28:40 +05:30
- when 'User'
- if version.event == 'update'
user
= link_to_user(version.item_id)
- unless %w(Conference Subscription Registration User Organization).include?(version.item_type)
- if (version.item_type == 'Role' && role_name == 'organization_admin') || (version.item_type == 'UsersRole' && role_name == 'organization_admin')
in organization
- if Organization.find_by(id: version.conference_id)
-# organization_admin belongs to organization and not conferences
- organization = Organization.find_by(id: version.conference_id)
2017-10-20 23:38:59 +05:30
= link_to_organization(version.conference_id)
- else
(Organization Deleted)
- elsif version.item_type == 'Commercial'
- commercial = current_or_last_object_state(version.item_type, version.item_id)
- commercialable = current_or_last_object_state(commercial.commercialable_type, commercial.commercialable_id)
- unless commercial.commercialable_type == 'Conference'
in conference
= link_to_conference(version.conference_id)
- else
in conference
= link_to_conference(version.conference_id)