This commit is contained in:
Nicolas Bally 2015-11-01 18:50:03 +01:00
parent 93a8bc72d8
commit ec1f1ae71a
24 changed files with 264 additions and 238 deletions

View File

@ -0,0 +1,70 @@
class Admin::ContactsController < ApplicationController
layout "admin"
before_filter :auth_admin
def index
@contacts = Contact.order("created_at DESC").all
end
def show
@contact = Contact.find(params[:id])
if @contact.readed != true
@contact.readed = true
@contact.save
end
end
def new
@contact = Contact.new
end
def edit
@contact = Contact.find(params[:id])
end
def create
@contact = Contact.new(contact_params)
if @contact.save
@contacts = Contact.order("created_at DESC").all
else
render :action => "new"
end
end
def update
@contact = Contact.find(params[:id])
if @contact.update_attributes(contact_params)
else
render :action => "edit"
end
end
def destroy
@contact = Contact.find(params[:id])
@contact.destroy if @contact != @current_contact
end
private
def contact_params
params.require(:contact).permit!
end
end

View File

@ -1,66 +0,0 @@
class Admin::StudentUsersController < ApplicationController
layout "admin"
before_filter :auth_admin
def index
@student_users = StudentUser.all
end
def show
@student_user = StudentUser.find(params[:id])
end
def new
@student_user = StudentUser.new
end
def edit
@student_user = StudentUser.find(params[:id])
end
def create
@student_user = StudentUser.new(student_user_params)
if @student_user.save
redirect_to admin_student_users_path
else
render :action => "new"
end
end
def update
@student_user = StudentUser.find(params[:id])
if @student_user.update_attributes(student_user_params)
redirect_to admin_student_users_path
else
render :action => "edit"
end
end
def destroy
@student_user = StudentUser.find(params[:id])
@student_user.destroy if @student_user != @current_student_user
end
private
def student_user_params
params.require(:student_user).permit!
end
end

View File

@ -0,0 +1,24 @@
%tr.vertical_center.contact#contact{:id => contact.id, :class => ("success" if !contact.readed)}
%td
=l contact.created_at
%td
=contact.name
%td
=contact.email
%td
=contact.tel
%td.actions
= link_to i(:"trash-o"), [:admin, contact], :confirm => 'Voulez-vous vraiment supprimer cet utilisateur ?', :method => :delete, :remote => true
= link_to i(:pencil), edit_admin_contact_path(contact), :remote => true
= link_to i(:eye), [:admin, contact]

View File

@ -0,0 +1,27 @@
= semantic_form_for [:admin, @contact], :remote => true do |f|
.content
=f.inputs do
= f.input :readed, :label => "Lu ?"
= f.input :name, :label => "Nom"
= f.input :email, :label => "Email"
= f.input :tel, :label => "Téléphone"
= f.input :place, :label => "Lieu"
= f.input :message, :label => "Message"
= f.input :address, :label => "Adresse"
= f.input :address2, :label => "Adresse (suite)"
= f.input :cp, :label => "Code postal"
= f.input :city, :label => "Ville"
= f.input :country, :label => "Pays", :as => :string
= f.input :notes, :label => "Notes"
.actions
=f.submit "Sauvegarder", :class => "btn btn-primary"

View File

@ -0,0 +1,63 @@
%table.table
%tr
%td
Date
%td
=l @contact.created_at
%tr
%td
Nom
%td
=@contact.name
%tr
%td
Email
%td
=@contact.email
%tr
%td
Téléphone
%td
=@contact.tel
%tr
%td
Lieu
%td
=@contact.place
%hr
=simple_format @contact.message
%hr
%table.table
%tr
%td
Adresse
%td
=@contact.address
%tr
%td
Adresse suite
%td
=@contact.address2
%tr
%td
Ville
%td
=@contact.cp
=@contact.city
%tr
%td
Pays
%td
=@contact.country
%hr
=simple_format @contact.notes
%hr

View File

@ -0,0 +1,2 @@
$('#admin_rows').html("<%= escape_javascript(render(@contacts))%>");
close_pane_hover();

View File

@ -0,0 +1,44 @@
= link_to 'Ajouter un contact', new_admin_contact_path, :class => "btn btn-primary", :style => "float:right;", :remote => true
%h1 Liste des contacts
%table.table.table-hover
%thead#Admin_rows_header.rows_header
%tr
%td
Date
%td
Nom
%td
Email
%td
Tel
%td{:style => "width:150px"}
&nbsp;
%tbody#admin_rows.rows
=render @contacts

View File

@ -0,0 +1,6 @@
= link_to i(:pencil), edit_admin_contact_path(@contact), :remote => true
= link_to "retour", admin_contacts_path(), :class => "btn btn-primary"
#show=render :partial => "show"

View File

@ -0,0 +1,4 @@
$('#show').html("<%= escape_javascript(render(:partial => "show"))%>");
$('#contact_<%= @contact.id %>').replaceWith("<%= escape_javascript(render(@contact))%>");
close_pane_hover();

View File

@ -1,72 +0,0 @@
= semantic_form_for [:admin, @student_user] do |f|
%hr
.row
.col-md-4
=f.input :lock, :label => "Verouillé"
=l f.object.locked_at if f.object.lock
.col-md-4
=f.input :student_group, :as => :check_boxes, :collection => StudentGroup.all, :label => "Groupe d'étudiant"
%hr
.row
.col-md-4
= f.input :name, :label => "Nom"
.col-md-4
= f.input :firstname, :label => "Prénom"
.col-md-4
=image_tag(f.object.avatar.square.url, :style => "height:4em;float:left;margin-right:10px;border-radius:50%;") if f.object.avatar
= f.input :avatar, :label => "Image de profil"
.row
.col-md-4
= f.input :email, :label => "Email"
.col-md-4
= f.input :show_email, :label => "Permettre aux étudiants de voir mon mail ?" if f.object.id
.row
.col-md-4
= f.input :password, :label => "Mot de passe"
.col-md-4
= f.input :password_confirmation, :label => "Confirmation"
.col-md-4
.row
.col-md-4
= f.input :tel, :label => "Téléphone"
.col-md-4
= f.input :show_tel, :label => "Permettre aux étudiants de voir mon numéro ?" if f.object.id
.row
.col-md-4
= f.input :address, :label => "Adresse"
.col-md-4
= f.input :address2, :label => "Adresse (suite)"
.col-md-4
.row
.col-md-4
= f.input :cp, :label => "Code postal"
.col-md-4
= f.input :city, :label => "Ville"
.col-md-4
= f.input :country, :label => "Pays", :as => :string
=f.inputs do
= f.input :bio, :label => "Présentation"
%br
=f.submit "Sauvegarder", :class => "btn btn-primary"

View File

@ -1,30 +0,0 @@
%tr.vertical_center.student_user#student_user{:id => student_user.id}
%td=image_tag (student_user.avatar? ? student_user.avatar.square.url : ""), :class => "avatar", :style => "width:50px; border-radius:50%;"
%td=link_to student_user.firstname.to_s+" "+student_user.name.to_s, student_student_user_path(student_user)
%td
=student_user.cp
=student_user.city
-if student_user.country?
="-"
=student_user.country
%td
=student_user.email
%td
=student_user.tel
%td
="Verouillé" if student_user.lock
-if !@student_group
%td.actions
= link_to i(:"trash-o"), [:admin, student_user], :confirm => 'Voulez-vous vraiment supprimer cet utilisateur ?', :method => :delete, :remote => true
= link_to i(:pencil), edit_admin_student_user_path(student_user)

View File

@ -1,2 +0,0 @@
$('#admin_rows').html("<%= escape_javascript(render(@admins))%>");
close_pane_hover();

View File

@ -1,45 +0,0 @@
= link_to 'Ajouter un utilisateur', new_admin_student_user_path, :class => "btn btn-primary", :style => "float:right;"
%h1 Liste des étudiants
%table.table.table-hover
%thead#Admin_rows_header.rows_header
%tr
%td
%td
Nom
%td
Adresse
%td
Email
%td
Téléphone
%td{:style => "width:100px"}
&nbsp;
%tbody#admin_rows.rows
=render @student_users

View File

@ -1,3 +0,0 @@
$('#admin_row_<%= @admin.id %>').replaceWith("<%= escape_javascript(render(@admin))%>");
close_pane_hover();

View File

@ -35,24 +35,8 @@
%ul.nav.navbar-nav
%li= link_to "admins", admin_admins_path
%li
-Menu.all.each do |menu|
= link_to "Pages", admin_menu_items_path(:menu_id => menu.id)
%li= link_to "témoignages", admin_testimonies_path
%li.dropdown
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
Etudiants
%ul.dropdown-menu
%li= link_to "Etudiants", admin_student_users_path
%li= link_to "Ressources", admin_topics_path
%li.divider
%li= link_to "Groupe d'étudiants", admin_student_groups_path
%li= link_to "Images", admin_image_files_path
%li= link_to "Fichiers", admin_data_files_path
%li= link_to "Contacts", admin_contacts_path

View File

@ -90,7 +90,7 @@ CMSnb::Application.routes.draw do
end
namespace :admin do
resources :student_users
resources :contacts
resources :student_groups
resources :note_files
resources :notes

View File

@ -0,0 +1,12 @@
class AddInfosToContacts < ActiveRecord::Migration
def change
add_column :contacts, :address, :string
add_column :contacts, :address2, :string
add_column :contacts, :cp, :string
add_column :contacts, :city, :string
add_column :contacts, :country, :string
add_column :contacts, :notes, :text
add_column :contacts, :statut, :string
add_column :contacts, :readed, :boolean
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20141106180846) do
ActiveRecord::Schema.define(version: 20151101172457) do
create_table "admins", force: true do |t|
t.string "name"
@ -154,6 +154,14 @@ ActiveRecord::Schema.define(version: 20141106180846) do
t.datetime "created_at"
t.datetime "updated_at"
t.string "place"
t.string "address"
t.string "address2"
t.string "cp"
t.string "city"
t.string "country"
t.text "notes"
t.string "statut"
t.boolean "readed"
end
create_table "content_types", force: true do |t|