You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
8 years ago
|
require 'geocoder/calculations'
|
||
|
|
||
|
class AdminController < ApplicationController
|
||
|
def new
|
||
|
return do_404 unless logged_in? && current_user.administrator?
|
||
|
@this_conference = Conference.new
|
||
|
@page_title = 'articles.conferences.headings.new'
|
||
|
end
|
||
|
|
||
|
def edit
|
||
|
return do_404 unless logged_in? && current_user.administrator?
|
||
|
@this_conference = Conference.find_by!(slug: params[:slug])
|
||
|
@page_title = 'articles.conferences.headings.edit'
|
||
|
render 'new'
|
||
|
end
|
||
|
|
||
|
def save
|
||
|
conference = params[:id].present? ? Conference.find_by!(id: params[:id]) : Conference.new
|
||
|
|
||
|
if params[:button] == 'save'
|
||
|
city = City.search(params[:city])
|
||
|
conference.city_id = city.id
|
||
|
conference.conferencetype = params[:type]
|
||
|
conference.year = params[:year].to_i
|
||
|
conference.is_public = params[:is_public].present?
|
||
|
conference.is_featured = params[:is_featured].present?
|
||
|
conference.make_slug(true)
|
||
|
conference.save!
|
||
|
elsif params[:button] == 'delete'
|
||
|
conference.destroy
|
||
|
return redirect_to conferences_url
|
||
|
end
|
||
|
|
||
|
redirect_to conference_url(conference.slug)
|
||
|
end
|
||
|
end
|