forked from openstreetmap/openstreetmap-website
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0021, 0217, 0220 Allow user to cancel their intention to attend an event. 0022, 0217, 0222? Show event attendees. Add attendees of an event, reformat some dates 0024 Translate all the things. 0055 Use .user_cards for event attendances too. 0092 Disable 1 button 0176 Add events to header. 0179 Add yes and no traits to event attendance factory. 0189 Add tests for routing. 0217 Not going to force user to belong to community in order to attend event. When using constants instead of strings, use them everywhere. 0219 Create update_params for update and add another test. Finish writing tests for EventAttendancesController. 0220 Handle plurals better 0228 If the user is not signed in, provide a link to login before having them RSVP. 0230 No need for :login_link. We just display a sentence with no params. 0231 Add maybe constant and convenience functions. Convert event attendance intention to enum. 0273 Display RSVPs as cards using a partial. User can only update their own RSVP. Use "could not be" phrasing.
- Loading branch information
Showing
15 changed files
with
472 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class EventAttendancesController < ApplicationController | ||
layout "site" | ||
before_action :authorize_web | ||
before_action :set_event_attendance, :only => [:update] | ||
|
||
authorize_resource | ||
|
||
def create | ||
attendance = EventAttendance.new(event_attendance_params) | ||
if attendance.save | ||
redirect_to event_path(attendance.event), :notice => t(".success") | ||
else | ||
redirect_to event_path(attendance.event), :alert => t(".failure") | ||
end | ||
end | ||
|
||
def update | ||
respond_to do |format| | ||
if @event_attendance.update(update_params) | ||
format.html { redirect_to @event_attendance.event, :notice => t(".success") } | ||
else | ||
format.html { redirect_to :edit, :alert => t(".failure") } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_event_attendance | ||
@event_attendance = EventAttendance.find(params[:id]) | ||
end | ||
|
||
def event_attendance_params | ||
params.require(:event_attendance).permit(:event_id, :user_id, :intention) | ||
end | ||
|
||
def update_params | ||
params.require(:event_attendance).permit(:intention) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# == Schema Information | ||
# | ||
# Table name: event_attendances | ||
# | ||
# id :bigint(8) not null, primary key | ||
# user_id :integer not null | ||
# event_id :integer not null | ||
# intention :enum not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_event_attendances_on_event_id (event_id) | ||
# index_event_attendances_on_user_id (user_id) | ||
# | ||
|
||
class EventAttendance < ApplicationRecord | ||
module Intentions | ||
YES = "Yes".freeze | ||
NO = "No".freeze | ||
MAYBE = "Maybe".freeze | ||
ALL_INTENTIONS = [YES, NO, MAYBE].freeze | ||
end | ||
validates :intention, :inclusion => { :in => Intentions::ALL_INTENTIONS } | ||
|
||
belongs_to :event | ||
belongs_to :user | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class CreateEventAttendances < ActiveRecord::Migration[7.0] | ||
def up | ||
create_enumeration :event_attendances_intention_enum, %w[Maybe No Yes] | ||
create_table :event_attendances do |t| | ||
t.references :user, :foreign_key => true, :null => false, :index => true | ||
t.references :event, :foreign_key => true, :null => false, :index => true | ||
t.column :intention, :event_attendances_intention_enum, :null => false | ||
|
||
t.timestamps | ||
end | ||
add_index :event_attendances, [:user_id, :event_id], :unique => true | ||
end | ||
|
||
def down | ||
drop_table :event_attendances | ||
drop_enumeration :event_attendances_intention_enum | ||
end | ||
end |
Oops, something went wrong.