mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Implements Contacts
This commit is contained in:
parent
4955b2b7b8
commit
eb3e6898d2
9 changed files with 156 additions and 5 deletions
43
app/controllers/admin/contacts_controller.rb
Normal file
43
app/controllers/admin/contacts_controller.rb
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
class Admin::ContactsController < ApplicationController
|
||||
before_action :set_conference
|
||||
before_action :set_contact, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /:conference/contact
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /:conference/contact/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# PATCH/PUT /:conference/contact
|
||||
def update
|
||||
if @contact.update(contact_params)
|
||||
redirect_to admin_conference_contact_path, notice: 'Contact details were successfully updated.'
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /:conference/contact
|
||||
def destroy
|
||||
@contact.destroy
|
||||
redirect_to admin_conference_contacts_url, notice: 'Contact details were successfully destroyed.'
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_contact
|
||||
@contact = @conference.contact
|
||||
end
|
||||
|
||||
def set_conference
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
end
|
||||
|
||||
# Only allow a trusted parameter "white list" through.
|
||||
def contact_params
|
||||
# params.require(:contact).permit(:social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public)
|
||||
params[:contact]
|
||||
end
|
||||
end
|
||||
|
|
@ -27,6 +27,8 @@ class Conference < ActiveRecord::Base
|
|||
|
||||
has_and_belongs_to_many :questions
|
||||
|
||||
has_one :contact, dependent: :destroy
|
||||
|
||||
has_one :email_settings, dependent: :destroy
|
||||
has_one :call_for_papers, dependent: :destroy
|
||||
has_many :social_events, dependent: :destroy
|
||||
|
|
@ -523,6 +525,10 @@ class Conference < ActiveRecord::Base
|
|||
|
||||
private
|
||||
|
||||
after_create do
|
||||
self.create_contact
|
||||
end
|
||||
|
||||
##
|
||||
# Calculates the weeks from a start and a end week.
|
||||
#
|
||||
|
|
|
|||
8
app/models/contact.rb
Normal file
8
app/models/contact.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class Contact < ActiveRecord::Base
|
||||
attr_accessible :conference, :social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public
|
||||
belongs_to :conference
|
||||
|
||||
validates :conference, presence: true
|
||||
# Conferences only have one contact
|
||||
validates :conference_id, :uniqueness => {:message => "has already contact details"}
|
||||
end
|
||||
31
app/views/admin/contacts/_form.html.haml
Normal file
31
app/views/admin/contacts/_form.html.haml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
= form_for @contact, url: admin_conference_contact_path do |f|
|
||||
- if @contact.errors.any?
|
||||
#error_explanation
|
||||
%h2= "#{pluralize(@contact.errors.count, "error")} prohibited this contact from being saved:"
|
||||
%ul
|
||||
- @contact.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.field
|
||||
= f.label :social_tag
|
||||
= f.text_field :social_tag
|
||||
.field
|
||||
= f.label :email
|
||||
= f.text_field :email
|
||||
.field
|
||||
= f.label :facebook
|
||||
= f.text_field :facebook
|
||||
.field
|
||||
= f.label :googleplus
|
||||
= f.text_field :googleplus
|
||||
.field
|
||||
= f.label :twitter
|
||||
= f.text_field :twitter
|
||||
.field
|
||||
= f.label :instagram
|
||||
= f.text_field :instagram
|
||||
.field
|
||||
= f.label :public
|
||||
= f.check_box :public
|
||||
.actions
|
||||
= f.submit 'Save'
|
||||
5
app/views/admin/contacts/edit.html.haml
Normal file
5
app/views/admin/contacts/edit.html.haml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
%h1 Editing contact
|
||||
|
||||
= render 'form'
|
||||
|
||||
= link_to 'Back', admin_conference_contact_path
|
||||
26
app/views/admin/contacts/show.html.haml
Normal file
26
app/views/admin/contacts/show.html.haml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
%p#notice= notice
|
||||
|
||||
%p
|
||||
%b Social tag:
|
||||
= @contact.social_tag
|
||||
%p
|
||||
%b Email:
|
||||
= @contact.email
|
||||
%p
|
||||
%b Facebook:
|
||||
= @contact.facebook
|
||||
%p
|
||||
%b Googleplus:
|
||||
= @contact.googleplus
|
||||
%p
|
||||
%b Twitter:
|
||||
= @contact.twitter
|
||||
%p
|
||||
%b Instagram:
|
||||
= @contact.instagram
|
||||
%p
|
||||
%b Public:
|
||||
= @contact.public
|
||||
|
||||
= link_to 'Edit', edit_admin_conference_contact_path
|
||||
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
Osem::Application.routes.draw do
|
||||
|
||||
|
||||
devise_for :users, controllers: { registrations: :registrations,
|
||||
omniauth_callbacks: 'users/omniauth_callbacks' },
|
||||
path: 'accounts'
|
||||
|
|
@ -8,6 +9,7 @@ Osem::Application.routes.draw do
|
|||
resources :users
|
||||
resources :people
|
||||
resources :conference do
|
||||
resource :contact, except: [:index, :new, :create]
|
||||
resource :schedule, only: [:show, :update]
|
||||
get '/stats' => 'stats#index'
|
||||
get '/venue' => 'venue#show', as: 'venue_info'
|
||||
|
|
|
|||
17
db/migrate/20140731153332_create_contacts.rb
Normal file
17
db/migrate/20140731153332_create_contacts.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class CreateContacts < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :contacts do |t|
|
||||
t.string :social_tag
|
||||
t.string :email
|
||||
t.string :facebook
|
||||
t.string :googleplus
|
||||
t.string :twitter
|
||||
t.string :instagram
|
||||
|
||||
t.boolean :public
|
||||
t.integer :conference_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
23
db/schema.rb
23
db/schema.rb
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140724113107) do
|
||||
ActiveRecord::Schema.define(version: 20140731153332) do
|
||||
|
||||
create_table "ahoy_events", force: true do |t|
|
||||
t.uuid "visit_id"
|
||||
|
|
@ -133,6 +133,19 @@ ActiveRecord::Schema.define(version: 20140724113107) do
|
|||
t.integer "question_id"
|
||||
end
|
||||
|
||||
create_table "contacts", force: true do |t|
|
||||
t.string "social_tag"
|
||||
t.string "email"
|
||||
t.string "facebook"
|
||||
t.string "googleplus"
|
||||
t.string "twitter"
|
||||
t.string "instagram"
|
||||
t.boolean "public"
|
||||
t.integer "conference_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "delayed_jobs", force: true do |t|
|
||||
t.integer "priority", default: 0, null: false
|
||||
t.integer "attempts", default: 0, null: false
|
||||
|
|
@ -487,8 +500,8 @@ ActiveRecord::Schema.define(version: 20140724113107) do
|
|||
|
||||
create_table "venues", force: true do |t|
|
||||
t.string "guid"
|
||||
t.text "name", limit: 255
|
||||
t.text "address", limit: 255
|
||||
t.text "name"
|
||||
t.text "address"
|
||||
t.string "website"
|
||||
t.text "description"
|
||||
t.string "offline_map_url"
|
||||
|
|
@ -499,8 +512,8 @@ ActiveRecord::Schema.define(version: 20140724113107) do
|
|||
t.string "photo_content_type"
|
||||
t.integer "photo_file_size"
|
||||
t.datetime "photo_updated_at"
|
||||
t.boolean "include_venue_in_splash", default: false
|
||||
t.boolean "include_lodgings_in_splash", default: false
|
||||
t.boolean "include_venue_in_splash", default: false
|
||||
t.boolean "include_lodgings_in_splash", default: false
|
||||
end
|
||||
|
||||
create_table "versions", force: true do |t|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue