Skip to content

Commit

Permalink
Merge pull request #534 from srogers/develop
Browse files Browse the repository at this point in the history
Release v135
  • Loading branch information
srogers authored Dec 31, 2021
2 parents 2aa5bb7 + b445bf9 commit 1a611cd
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 52 deletions.
2 changes: 2 additions & 0 deletions app/assets/javascripts/publications.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ $ ->
$format_selector.val("Campus")
else if url.includes("estore.aynrand")
$format_selector.val("e-Store")
else if url.includes("podcast")
$format_selector.val("Podcast")
2 changes: 1 addition & 1 deletion app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def get_current_user

def user_params
params.require(:user).permit(:password, :password_confirmation, :email, :name, :city, :state, :country, :photo, :remove_photo,
:time_zone, :show_attendance, :show_contributor, :compact_presentations, :time_format)
:time_zone, :show_attendance, :show_contributor, :time_format)
end
end
13 changes: 0 additions & 13 deletions app/models/presentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Presentation < ApplicationRecord
has_many :users, through: :user_presentations # answers: who's watching this presentation

validates :name, presence: true
validate :unique_per_conference
# requiring a speaker at create is handled by PresentationsController

before_save :update_sortable_name, :adjust_series_bounds
Expand Down Expand Up @@ -69,18 +68,6 @@ def adjust_series_bounds
end
end

# presentations can exist with duplicate names, but presentation names must be unique within a conference
def unique_per_conference
if conference_id.present?
if id.present?
duplicate_count = Presentation.where("name = ? AND id != ? AND conference_id = ?", name, id, conference_id).length
else
duplicate_count = Presentation.where("name = ? AND conference_id = ?", name, conference_id).length
end
errors.add(:conference, "already has a presentation with the same name.") if duplicate_count > 0
end
end

def speaker_names
speakers.map{|s| s.name}.join(", ")
end
Expand Down
1 change: 0 additions & 1 deletion app/views/accounts/_form_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
= f.input :show_attendance, as: :boolean, label: "Allow other users to see my event attendance"
- if @user.editor? || @user.admin?
= f.input :show_contributor, as: :boolean, label: "List me on the Supporters page as a contributing editor"
= f.input :compact_presentations, as: :boolean, label: "Use compact format for presentation listing"
= f.input :time_format, as: :select, collection: Publication::TIME_FORMATS, include_blank: false, label: 'Publication Time Format'
7 changes: 0 additions & 7 deletions app/views/accounts/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@
%span.confirm= icon('fas', 'check')
- else
%span.deny= icon('fas', 'times')
.row
.col-sm-8.text-right Use compact format for presentation listing
.col-sm-4.font-weight-bold
- if @user.compact_presentations
%span.confirm= icon('fas', 'check')
- else
%span.deny= icon('fas', 'times')

.row
.col-sm-8.text-right Display format for times in publications
Expand Down
2 changes: 1 addition & 1 deletion app/views/events/_presentations_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
= [ sorting_header('Date', :event_path, 'presentations.date', icon: 'sort-numeric'), @conference.multi_venue? ? 'Location' : nil].compact.join(' / ').html_safe
- if params[:heart].present?
.col Needs
.col.col-md-1.text-right Media
.col.col-md-1.text-center Media
.col.d-none.d-md-block
2 changes: 1 addition & 1 deletion app/views/pages/guidelines.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
can be some subtle consequences for these choices in terms of how things show up in searches and charts.
%p
The webinar series
= link_to 'Philosophy for Living On Earth', events_path('philosophy-for-living-on-earth')
= link_to 'Philosophy for Living On Earth', event_path('philosophy-for-living-on-earth')
is a good example of a virtual event with no location. There are no physical attendees, just webinar participants.
The
= link_to "ARI Road to a Free Society", event_path('ari-road-to-a-free-society')
Expand Down
2 changes: 1 addition & 1 deletion app/views/pages/tips.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
%p
Series events contain thematically related presentations over an extended period, but without the
structure of a conference. A series with virtual presentations (such as the
= link_to 'Philosophy for Living On Earth', events_path('philosophy-for-living-on-earth')
= link_to 'Philosophy for Living On Earth', event_path('philosophy-for-living-on-earth')
webinars) has no location.
A series may have multiple locations (such as the
= link_to "ARI Road to a Free Society", event_path('ari-road-to-a-free-society')
Expand Down
2 changes: 1 addition & 1 deletion app/views/presentations/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- if params[:heart].present?
.col Needs

.col.col-sm-2.col-md-2.text-right
.col.col-sm-2.col-md-2.text-center
Media

- if current_user.present?
Expand Down
23 changes: 6 additions & 17 deletions app/views/presentations/_presentation.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,19 @@
.row.mb-2{ id: "presentation_#{presentation.id}" }
%div{ class: current_user.present? ? 'col-md-5' : 'col-md-8'}
-# Make the detailed view the default - see what indexing robots do with that - use compact for speakers
-if (controller_name != 'presentations' && current_user&.compact_presentations) || controller_name == 'speakers'
-# For compact use just the name for event presentation listing. Never include speaker in speaker presentation listing - redundant
-if @conference.present? # then it's the event listing, so show speakers but not tags
- if @conference && @conference.use_episodes
= presentation.episode
= link_to(truncate(presentation.name, length: 80, separator: ' '), presentation_path(presentation))
-elsif current_user&.compact_presentations
%br
by
= clickable_speaker_list(presentation)
-else
.detail-selector
= link_to icon('far', 'caret-square-right', class: 'fa-fw'), "#", class: 'detail-show', style: 'display: none;', title: ht_details
= link_to icon('far', 'caret-square-down', class: 'fa-fw'), "#", class: 'detail-hide', style: 'display: none;', title: ht_hide_details
= link_to icon('far', 'caret-square-right', class: 'fa-fw'), presentation_path(presentation), class: 'detail-initiator', rel: 'nofollow', data: { method: :get, remote: true, params: { details: true, skip_event: (controller_name == 'events' && action_name == 'show') }.to_param }, title: ht_details
= link_to(truncate(presentation.name, length: 80, separator: ' '), presentation_path(presentation))
-else
- if @conference && @conference.use_episodes
= presentation.episode
= link_to(truncate(presentation.name, length: 80, separator: ' '), presentation_path(presentation))
%br
by
= clickable_speaker_list(presentation)
- unless controller_name == 'events' && params[:id].present? # in that case, we're looking at the event page - reiterating event is redundant
- if presentation.conference.present? && params[:skip_event] != 'true'
at
= link_to truncate(presentation.conference_name, length: 45, separator: ' '), event_path(presentation.conference)
%br
= linked_tag_names(presentation, class: 'slim')

-if @conference.present? # then it's the event listing
.col.col-sm-8.col-md-2
Expand Down Expand Up @@ -59,7 +48,7 @@
= icon('fas', 'puzzle-piece', class: 'fa-fw', title: 'Needs number of parts') if presentation.parts.blank?
= icon('fas', 'chalkboard-teacher', class: 'fa-fw', title: 'Not yet associated with an event') if presentation.conference.blank?

.col.col-sm-2.col-md-2.text-right= linked_format_icons(presentation)
.col.col-sm-2.col-md-2.text-center= linked_format_icons(presentation)

-# Jam the heart and edit buttons into one column - the heart takes up too much space in a column by itself
- if current_user.present?
Expand Down
3 changes: 2 additions & 1 deletion app/views/presentations/manage_publications.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

= link_to icon('far', 'edit', :class => 'fa-fw'), edit_publication_path(publication, presentation_id: @presentation.id)
= link_to icon('fas', 'unlink', :class => 'fa-fw'), presentation_publication_path(presentation_publication), :method => :delete, :post => true, class: 'text-danger'
= link_to icon('far', 'trash-alt', :class => 'fa-fw'), publication_path(publication, presentation_id: presentation_publication.presentation_id), :method => :delete, :data => { :confirm => 'remove this publication permanently?' }, :post => true, class: 'text-danger'
-# Don't allow delete here - too easy to slip up - follow the "eye" link to show, and delete there
=# link_to icon('far', 'trash-alt', :class => 'fa-fw'), publication_path(publication, presentation_id: presentation_publication.presentation_id), :method => :delete, :data => { :confirm => 'remove this publication permanently?' }, :post => true, class: 'text-danger'

.row
.col-md-12
Expand Down
2 changes: 1 addition & 1 deletion app/views/speakers/_presentations_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- if params[:heart].present?
.col Needs

.col.col-sm-2.col-md-2.text-right
.col.col-sm-2.col-md-2.text-center
Media

- if current_user.present?
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20211230162139_remove_compact_presentations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveCompactPresentations < ActiveRecord::Migration[5.2]
def change
remove_column "users", :compact_presentations, :boolean, default: false
end
end
3 changes: 1 addition & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2021_12_25_153946) do
ActiveRecord::Schema.define(version: 2021_12_30_162139) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -329,7 +329,6 @@
t.integer "speaker_id"
t.string "sortable_name"
t.string "time_format", default: "hh:mm"
t.boolean "compact_presentations", default: false
t.string "privacy_policy_version", default: "0.0"
t.index ["sortable_name"], name: "index_users_on_sortable_name"
end
Expand Down
17 changes: 12 additions & 5 deletions spec/models/presentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,19 @@

let!(:duplicate_presentation) { create :presentation, name: valid_attributes[:name], conference_id: conference.id }

it "can't be associated with that conference" do
expect { Presentation.create!(valid_attributes.merge(conference_id: conference.id)) }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Conference already has a presentation with the same name.")
# This reverses an earlier validation that prevented duplicate names. That seemed like a sensible
# restriction, but it turns out the be just a pain, because series and tour events sometimes legitimately
# have presentations with the same name.
it "can be associated with that conference" do
presentation = Presentation.create!(valid_attributes.merge(conference_id: conference.id))
expect(presentation).to be_valid
end
end

context "series" do
let!(:dummy) { conference.update(event_type: Conference::SERIES) }
# only series does this, because for conferences, a presentation date outside the window is probably a user error
# Only series does this, because for conferences, a presentation date outside the window is probably a user error.
# A series is always getting new presentations, so it's convenient for the date to just extend automatically.
it "extends the series start date if the presentation date falls before" do
presentation = Presentation.new(valid_attributes.merge(conference_id: conference.id, date: conference.start_date - 1.day ))
expect(presentation).to be_valid
Expand Down Expand Up @@ -125,8 +130,10 @@

let!(:duplicate_presentation) { create :presentation, name: presentation.name, conference_id: conference.id }

it "can't be associated with that conference" do
expect { presentation.update_attributes!(conference_id: conference.id) }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Conference already has a presentation with the same name.")
# This reverses an earlier validation preventing duplicate names, because that restriction is really just unhelpful
it "can be associated with that conference" do
presentation.update_attributes!(conference_id: conference.id)
expect(presentation).to be_valid
end
end
end
Expand Down

0 comments on commit 1a611cd

Please sign in to comment.