Skip to content

Commit

Permalink
Merge pull request #37 from rubymonsters/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
zaziemo committed Oct 5, 2015
2 parents b42c6d8 + 793d638 commit 98c0a59
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,73 +17,98 @@
body {
margin: 0;
}
a {

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

a {
color: #898989;
}

h1 {
color: #337389;
}

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

/* Navigation Bar */
.topbar {
padding: 0 15px;
background-color: #eff0ec;
font-family: sans-serif;
}

.topbar a {
text-decoration: none;
color: #898989;
}
a {
text-decoration: none;
color: #898989;
}

.topbar h1 {
display: inline-block;
h1 {
display: inline-block;
}

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

.navigation {
display: inline-block;
}

.navigation li {
padding: 0 5px;
display: inline-block;
list-style: none;
li {
padding: 0 5px;
display: inline-block;
list-style: none;
}
}

/* Admin Show Page */
.row li {
display: inline-block;
width: 150px;
}

.content {
font-family: sans-serif;
padding: 0 15px;
color: #898989;
}
/* New Events Page (Form) */
.form_field {
margin-top: 0.75em;

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

.topbar .button {
background-color: #898989;
color: #eff0ec;
}
input[type=text] {
width: 35em;
}

.form_field {
margin-top: 0.75em;
textarea {
width: 35em;
height: 10em;
}
}

.form_field p {
margin: 0;
}
.date {
overflow: hidden;

.form_field input[type=text] {
width: 35em;
}
.left {
float: left;
margin-right: 10px;
}

.form_field textarea {
width: 35em;
height: 10em;
}
.right {
float: left;
}
}
9 changes: 5 additions & 4 deletions app/controllers/applications_controller.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
class ApplicationsController < ApplicationController
http_basic_authenticate_with name: ENV['DT_USERNAME'], password: ENV['DT_PASSWORD'], only: :show
before_action :get_event, only: [:show, :new, :create]

def show
@event = Event.find(params[:event_id])
@application = @event.applications.find(params[:id])
end

def new
@event = Event.find(params[:event_id])
@application = @event.applications.build
end

def create
@event = Event.find(params[:event_id])

@application = Application.new(application_params)
@application.event = @event
if @application.save
Expand All @@ -27,4 +24,8 @@ def create
def application_params
params.require(:application).permit(:name, :email, :email_confirmation, :answer_1, :answer_2, :answer_3)
end

def get_event
@event = Event.find(params[:event_id])
end
end
9 changes: 5 additions & 4 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +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]

def index
@events = Event.approved
Expand All @@ -10,7 +11,6 @@ def admin_index
end

def admin_show
@event = Event.find(params[:id])
respond_to do |format|
format.html
format.csv { send_data @event.to_csv }
Expand All @@ -36,12 +36,9 @@ def create
end

def edit
@event = Event.find(params[:id])
end

def update
@event = Event.find(params[:id])

if @event.update(event_params)
redirect_to admin_path
else
Expand All @@ -53,4 +50,8 @@ def update
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)
end

def get_event
@event = Event.find(params[:id])
end
end
143 changes: 72 additions & 71 deletions app/views/events/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,93 +14,94 @@
<%= form_for :event, url: events_path do |f| %>
<div class="form_field">
<p>
<%= f.label :organizer_name %>
</p>
<p>
<%= f.text_field :organizer_name %>
</p>
</div>
<p>
<%= f.label :organizer_name %>
</p>
<p>
<%= f.text_field :organizer_name %>
</p>
</div>

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

<div class="form_field">
<p>
<%= f.label :organizer_email_confirmation %>
</p>
<p>
<%= f.text_field :organizer_email_confirmation %>
</p>
</div>
<p>
<%= f.label :organizer_email_confirmation %>
</p>
<p>
<%= f.text_field :organizer_email_confirmation %>
</p>
</div>

<div class="form_field">
<p>
<%= f.label :description %>
</p>
<%= f.text_area :description %>
</div>
<p>
<%= f.label :description %>
</p>
<%= f.text_area :description %>
</div>

<div class="form_field">
<p>
<%= f.label :name %>
</p>
<p>
<%= f.text_field :name %>
</p>
</div>
<p>
<%= f.label :name %>
</p>
<p>
<%= f.text_field :name %>
</p>
</div>

<div class="form_field">
<p>
<%= f.label :start_date %>
</p>
<p>
<%= f.date_field :start_date %>
</p>
</div>
<div class="date">
<div class="form_field left">
<p>
<%= f.label :start_date %>
</p>
<p>
<%= f.date_field :start_date %>
</p>
</div>

<div class="form_field">
<p>
<%= f.label :end_date %>
</p>
<p>
<%= f.date_field :end_date %>
</p>
</div>
<div class="form_field right">
<p>
<%= f.label :end_date %>
</p>
<p>
<%= f.date_field :end_date %>
</p>
</div>
</div>

<div class="form_field">
<p>
<%= f.label :question_1 %>
</p>
<p>
<%= f.text_field :question_1 %>
</p>
</div>
<p>
<%= f.label :question_1 %>
</p>
<p>
<%= f.text_field :question_1 %>
</p>
</div>

<div class="form_field">
<p>
<%= f.label :question_2 %>
</p>
<p>
<%= f.text_field :question_2 %>
</p>
</div>
<p>
<%= f.label :question_2 %>
</p>
<p>
<%= f.text_field :question_2 %>
</p>
</div>

<div class="form_field">
<p>
<%= f.label :question_3 %>
</p>
<p>
<%= f.text_field :question_3 %>
</p>
</div>

<p>
<%= f.label :question_3 %>
</p>
<p>
<%= f.text_field :question_3 %>
</p>
</div>

<p>
<%= f.submit %>
Expand Down

0 comments on commit 98c0a59

Please sign in to comment.