Skip to content

Commit

Permalink
Merge pull request #65 from rubymonsters/fix-event-views
Browse files Browse the repository at this point in the history
Fix event views – closes #61, closes #53, closes #50, closes #48, closes #47, closes #44, closes #36, closes #57, closes #51!
  • Loading branch information
joecorcoran committed Oct 12, 2015
2 parents 98c0a59 + 8f78240 commit b337515
Show file tree
Hide file tree
Showing 14 changed files with 198 additions and 221 deletions.
45 changes: 34 additions & 11 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

body {
margin: 0;
font-family: sans-serif;
}

.content {
font-family: sans-serif;
padding: 0 15px;
color: #898989;

Expand All @@ -36,7 +36,6 @@ body {
color: #ffffff;
padding: 0.5em;
border-radius: 5px;
margin: 0 1em;
text-decoration: none;
}
}
Expand All @@ -55,15 +54,6 @@ body {
h1 {
display: inline-block;
}

.button {
background-color: #898989;
color: #eff0ec;
padding: 0.5em;
border-radius: 5px;
margin: 0 1em;
text-decoration: none;
}
}

.navigation {
Expand Down Expand Up @@ -98,6 +88,21 @@ body {
width: 35em;
height: 10em;
}

input[type=submit] {
font-family: sans-serif;
font-size: 14px;
background-color: #898989;
color: #eff0ec;
padding: 0.5em;
border-radius: 5px;
margin: 0;
text-decoration: none;
}

.radio-button {
font-size: 12px;
}
}

.date {
Expand All @@ -112,3 +117,21 @@ body {
float: left;
}
}
/* Event Show Page */
.event {
background-color: #EBCDC3;
padding: 5px 15px 30px 15px;
margin: 10px 0;
width: 35em;
border-radius: 5px;

p {
margin-bottom: 25px;
}
}

/* Messages */
.notice {
padding: 15px;
color: #dc4136;
}
7 changes: 6 additions & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class EventsController < ApplicationController
http_basic_authenticate_with name: ENV['DT_USERNAME'], password: ENV['DT_PASSWORD'], only: [:admin_index, :admin_show, :edit]
before_action :get_event, only: [:admin_show, :edit, :update]
before_action :get_event, only: [:admin_show, :edit, :update, :destroy]

def index
@events = Event.approved
Expand Down Expand Up @@ -46,6 +46,11 @@ def update
end
end

def destroy
@event.destroy
redirect_to admin_url
end

private
def event_params
params.require(:event).permit(:organizer_name, :organizer_email, :organizer_email_confirmation, :description, :name, :start_date, :end_date, :question_1, :question_2, :question_3, :approved)
Expand Down
6 changes: 3 additions & 3 deletions app/models/event.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class Event < ActiveRecord::Base
has_many :applications
has_many :applications, dependent: :destroy

validates :organizer_name, :description, :name, :question_1, presence: true
validates :organizer_name, :description, :name, presence: true
validates :start_date, date: true
validates :end_date, date: { after: :start_date }
validates :end_date, date: { after_or_equal_to: :start_date }
validates :organizer_email, confirmation: true, format: { with: /.+@.+\..+/ }, presence: true
validates :organizer_email_confirmation, presence: true, on: :create

Expand Down
63 changes: 26 additions & 37 deletions app/views/applications/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<h1>New Application for <%= @event.name %></h1>
<p><%= link_to 'Home', root_path %> > <%= link_to 'Events', events_path %> > <%= link_to @event.name, event_path(@event) %> > Application</p>

<h1>Application for <%= @event.name %></h1>

<%= form_for :application, url: event_applications_path(params[:event_id]) do |f| %>
Expand All @@ -13,44 +15,31 @@
</ul>
</div>
<% end %>

<p>
<%= f.label :name %><br>
<%= f.text_field :name %>
</p>

<p>
<%= f.label :email %><br>
<%= f.text_field :email %>
</p>

<p>
<%= f.label :email_confirmation %><br>
<%= f.text_field :email_confirmation %>
</p>

<p>
<%= f.label @event.question_1 %><br>
<%= f.text_field :answer_1 %>
</p>
<div class="form_field">
<p>
<%= f.label :name %><br>
<%= f.text_field :name %>
</p>
</div>

<% if @event.question_2.present? %>
<p>
<%= f.label @event.question_2 %><br>
<%= f.text_field :answer_2 %>
</p>
<% end %>
<div class="form_field">
<p>
<%= f.label :email %><br>
<%= f.text_field :email %>
</p>
</div>

<% if @event.question_3.present? %>
<p>
<%= f.label @event.question_3 %><br>
<%= f.text_field :answer_3 %>
</p>
<% end %>
<div class="form_field">
<p>
<%= f.label :email_confirmation %><br>
<%= f.text_field :email_confirmation %>
</p>
</div>

<p>
<%= f.submit %>
</p>
<div class="form_field">
<p>
<%= f.submit("Submit Application") %>
</p>
</div>
<% end %>
<%= link_to 'Back', event_path(params[:event_id]) %>
16 changes: 0 additions & 16 deletions app/views/applications/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,4 @@
</p>


<p>
<strong><%= @event.question_1 %></strong>
<%= @application.answer_1 %>
</p>

<p>
<strong><%= @event.question_2 %></strong>
<%= @application.answer_2 %>
</p>

<p>
<strong><%= @event.question_3 %></strong>
<%= @application.answer_3 %>
</p>


<%= link_to 'Show Event', event_path(@event.id) %>
10 changes: 5 additions & 5 deletions app/views/events/admin_index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<% @events.each do |event| %>
<p>
<%= link_to event.name, event_admin_path(:id => event.id) %>
<% if event.approved %>
<%= link_to 'Unapprove', edit_event_path(:id => event.id) %>
<% else %>
<%= link_to 'Approve', edit_event_path(:id => event.id) %>
<% end %>
<%= link_to 'Download CSV', event_admin_path(:id => event.id, :format => :csv) %>
<%= link_to 'Edit', edit_event_path(:id => event.id) %>
<%= link_to 'Delete', url_for(action: :destroy, id: event.id), method: :delete, data: { confirm: "Are you sure?" } %>
</p>
<% end %>
14 changes: 0 additions & 14 deletions app/views/events/admin_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,12 @@
<ul class="row">
<li>Name</li>
<li>Email</li>
<li><%= @event.question_1 %></li>
<% if @event.question_2.present? %>
<li><%= @event.question_2 %></li>
<% end %>
<% if @event.question_3.present? %>
<li><%= @event.question_3 %></li>
<% end %>
</ul>

<% @event.applications.each do |application| %>
<ul class="row">
<li><%= application.name %></li>
<li><%= application.email %></li>
<li><%= application.answer_1 %></li>
<% if @event.question_2.present? %>
<li><%= application.answer_2 %></li>
<% end %>
<% if @event.question_3.present? %>
<li><%= application.answer_3 %></li>
<% end %>
</ul>
<% end %>
Expand Down
100 changes: 57 additions & 43 deletions app/views/events/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,75 @@
</div>
<% end %>
<p>
<strong>Organizer Name:</strong>
<%= @event.organizer_name %>
</p>

<p>
<strong>Organizer Email:</strong>
<%= @event.organizer_email %>
</p>
<%= form_for @event, url: event_path(@event), method: :patch do |f| %>

<p>
<strong>Name:</strong>
<%= @event.name %>
</p>

<p>
<strong>Description:</strong>
<%= @event.description %>
</p>
<p>Event Details:</p>
<div class="form_field">
<p>
<%= f.label :name, 'Event Name' %>

<p>
<strong>Date:</strong>
<%= @event.start_date %>
</p>
<p>
<%= f.text_field :name %>
</p>
</div>

<strong>to</strong>
<%= @event.end_date %>
</p>
<div class="date">
<div class="form_field left">
<p>
<%= f.label :start_date, 'From' %>
</p>
<p>
<%= f.date_field :start_date %>
</p>
</div>

<p>
<strong>Question 1:</strong>
<%= @event.question_1 %>
</p>
<div class="form_field right">
<p>
<%= f.label :end_date, 'To' %>
</p>
<p>
<%= f.date_field :end_date %>
</p>
</div>
</div>

<p>
<strong>Question 2:</strong>
<%= @event.question_2 %>
</p>
<div class="form_field">
<p>
<%= f.label :description, 'Description' %>
</p>
<%= f.text_area :description %>
</div>

<p>
<strong>Question 3:</strong>
<%= @event.question_3 %>
</p>
<p>Organizer Details:</p>
<div class="form_field">
<p>
<%= f.label :organizer_name, 'Name' %>
</p>
<p>
<%= f.text_field :organizer_name %>
</p>
</div>

<div class="form_field">
<p>
<%= f.label :organizer_email, 'Email' %>
</p>
<p>
<%= f.text_field :organizer_email %>
</p>
</div>

<%= form_for @event, url: event_path(@event), method: :patch do |f| %>
<div class="field">
<div class="form_field">
<p>Approve Event?</p>
<p><%= label_tag do %>
<p class="radio-button"><%= label_tag do %>
<%= f.radio_button(:approved, true) %> Yes
<% end %></p>
<p><%= label_tag do %>
<% end %>
<%= label_tag do %>
<%= f.radio_button(:approved, false) %> No
<% end %></p>
</div>
<div class="actions">
<div class="form_field">
<%= f.submit %>
</div>
</div><br>
<% end %>
9 changes: 4 additions & 5 deletions app/views/events/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<h1>Listing Events</h1>

<% @events.each do |event| %>
<p>
<%= link_to event.name, event_path(:id => event.id) %>
<div class="event">
<h3><%= link_to event.name, event_path(:id => event.id) %></h3>
<p><%= event.description %></p>
<%= link_to 'Apply', new_event_application_path(:event_id => event.id), class:'button' %>
</p>
</div>
<% end %>

Loading

0 comments on commit b337515

Please sign in to comment.