Project

General

Profile

« Previous | Next » 

Revision d0ff9068

Added by Marc Dequènes about 16 years ago

  • ID d0ff90685657026f9316e7455a54dc35690a97eb

[evol] created a simple logon system, protected admin pages, and added a logon indicator/link (no user management yet, only a deadend entry in the menu if admin)

View differences:

app/controllers/admin.rb
module Admin
class AdminController < ApplicationController
before_filter :login_required
end
end
app/controllers/application.rb
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => '86f01f14fc184c81bf152965a2bccb88'
filter_parameter_logging :password
init_gettext MyCyma::Info::app_name
def initialize
......
render :template => "common/404", :layout => ! request.xhr?, :status => :not_found
return false
end
def login_required
if session[:user_id]
return true
end
flash[:warning] = _('Please login to continue')
session[:return_to] = request.request_uri
redirect_to :controller => "/logon", :action => "login"
return false
end
def current_user
@current_user ||= ((session[:user_id] && User.find_by_id(session[:user_id])) || nil)
end
def redirect_to_stored
if return_to = session[:return_to]
session[:return_to] = nil
redirect_to(return_to)
else
redirect_to :controller => 'welcome', :action => 'index'
end
end
end
app/views/layouts/application.rhtml
<div id="header">
<h1><%= link_to_unless_current "~°~ #{site_name} ~°~", root_path %></h1>
<ul class="nav" id="menu">
<%
current_user ||= ((session[:user_id] && User.find_by_id(session[:user_id])) || nil)
if current_user
%>
<li><strong><%= _("Setup the Cyma") %></strong>
<ul>
<li><%= link_to _("Manage Artworks"), admin_artworks_url %></li>
......
<li><%= link_to _("Manage Artwork Sets & Groups"), admin_artwork_sets_url %></li>
<li><%= link_to _("Manage Artwork Sizes"), admin_artwork_sizes_url %></li>
<li><%= link_to _("Manage Techniques"), admin_techniques_url %></li>
<% if current_user.admin %>
<li>-------</li>
<li><%= link_to _("Manage Users"), admin_users_url %></li>
<% end %>
</ul>
</li>
<% end %>
<li><strong><%= _("About") %></strong>
<ul>
<li><%= link_to _("Project page"), MyCyma::Info::url, :popup => true %></li>
......
</ul>
</li>
</ul>
<!-- <div id="user_info" style="float: right;text-align: center;"><%= session[:login] ? "Loggued in as '#{session[:login]}'<br/>(#{link_to "logout", { :controller => 'logon', :action => 'logout'}})" : "Not loggued in" %></div> -->
<div id="user_info" style="float: right;text-align: center;"><%= current_user ?
sprintf(_("Loggued in as '%s'"), current_user.login) + "<br/>(#{link_to _("logout"), { :controller => '/logon', :action => 'logout'}})" :
_("Not loggued in") + "<br/>(#{link_to _("login"), { :controller => '/logon', :action => 'login'}})"
%></div>
</div>
<div style="clear: both;"></div>
<%= render_flash_messages %>
config/routes.rb
admin.resources :artwork_conditions, :member => {:move => :put}
admin.resources :artwork_sets, :has_many => [ :artwork_groups ]
admin.resources :artworks, :has_many => [ :artwork_step_images ]
admin.resources :users
end
# Install the default routes as the lowest priority.
db/schema.rb
add_index "techniques", ["name", "acronym"], :name => "nom", :unique => true
add_index "techniques", ["name"], :name => "nom_2"
create_table "users", :force => true do |t|
t.string "login", :limit => 64, :null => false
t.string "real_name", :limit => 256
t.string "email", :limit => 128
t.string "hashed_password", :limit => 512, :null => false
t.string "salt", :limit => 64, :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "admin", :default => false, :null => false
end
add_index "users", ["login"], :name => "login", :unique => true
add_index "users", ["real_name"], :name => "real_name", :unique => true
end
po/MyCyma.pot
msgid ""
msgstr ""
"Project-Id-Version: MyCyma 0.1.0\n"
"POT-Creation-Date: 2008-09-18 23:59+0200\n"
"POT-Creation-Date: 2008-11-28 00:31+0100\n"
"PO-Revision-Date: 2008-07-28 02:17+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
msgid "ArtworkGroup|Comment"
msgstr ""
#: app/models/user.rb:-
msgid "user"
msgstr ""
#: app/models/user.rb:-
msgid "User|Login"
msgstr ""
#: app/models/user.rb:-
msgid "User|Real name"
msgstr ""
#: app/models/user.rb:-
msgid "User|Email"
msgstr ""
#: app/models/user.rb:-
msgid "User|Hashed password"
msgstr ""
#: app/models/user.rb:-
msgid "User|Salt"
msgstr ""
#: app/models/user.rb:-
msgid "User|Created at"
msgstr ""
#: app/models/user.rb:-
msgid "User|Updated at"
msgstr ""
#: app/models/user.rb:-
msgid "User|Admin"
msgstr ""
#: app/models/user.rb:11
msgid "Invalid email"
msgstr ""
#: app/models/artwork_condition.rb:-
msgid "artwork condition"
msgstr ""
......
msgid "New %s"
msgstr ""
#: app/helpers/application_helper.rb:126
#: app/views/admin/artwork_step_images/new.rhtml:5
#: app/views/admin/artwork_placement_reasons/new.rhtml:5
#: app/views/admin/artwork_materials/new.rhtml:5
#: app/views/admin/techniques/new.rhtml:5
#: app/views/admin/artwork_conditions/new.rhtml:5
#: app/views/admin/artwork_sets/new.rhtml:5
#: app/views/admin/artwork_sizes/new.rhtml:5
#: app/views/admin/artworks/new.rhtml:5
#: app/views/admin/artwork_groups/new.rhtml:5
msgid "Add"
msgstr ""
#: app/helpers/application_helper.rb:128
msgid "Cancel"
msgstr ""
......
msgid "Updated at:"
msgstr ""
#: app/controllers/application.rb:40
msgid "Please login to continue"
msgstr ""
#: app/controllers/logon_controller.rb:9
msgid "Login successful"
msgstr ""
#: app/controllers/logon_controller.rb:12
msgid "Login unsuccessful"
msgstr ""
#: app/views/welcome/index.rhtml:1
msgid "ArtBook Manager"
msgstr ""
......
msgid "Latest 10 Artworks"
msgstr ""
#: app/views/layouts/application.rhtml:20
#: app/views/layouts/application.rhtml:24
msgid "Setup the Cyma"
msgstr ""
#: app/views/layouts/application.rhtml:22
#: app/views/layouts/application.rhtml:26
msgid "Manage Artworks"
msgstr ""
#: app/views/layouts/application.rhtml:23
#: app/views/layouts/application.rhtml:27
msgid "Manage Artwork Conditions"
msgstr ""
#: app/views/layouts/application.rhtml:24
#: app/views/layouts/application.rhtml:28
msgid "Manage Artwork Materials"
msgstr ""
#: app/views/layouts/application.rhtml:25
#: app/views/layouts/application.rhtml:29
msgid "Manage Artwork Placement Reasons"
msgstr ""
#: app/views/layouts/application.rhtml:26
#: app/views/layouts/application.rhtml:30
msgid "Manage Artwork Sets & Groups"
msgstr ""
#: app/views/layouts/application.rhtml:27
#: app/views/layouts/application.rhtml:31
msgid "Manage Artwork Sizes"
msgstr ""
#: app/views/layouts/application.rhtml:28
#: app/views/layouts/application.rhtml:32
msgid "Manage Techniques"
msgstr ""
#: app/views/layouts/application.rhtml:31
#: app/views/layouts/application.rhtml:35
msgid "Manage Users"
msgstr ""
#: app/views/layouts/application.rhtml:40
msgid "About"
msgstr ""
#: app/views/layouts/application.rhtml:33
#: app/views/layouts/application.rhtml:42
msgid "Project page"
msgstr ""
#: app/views/layouts/application.rhtml:34
#: app/views/layouts/application.rhtml:43
msgid "Help"
msgstr ""
#: app/views/layouts/application.rhtml:48
msgid "Loggued in as '%s'"
msgstr ""
#: app/views/layouts/application.rhtml:49
msgid "Not loggued in"
msgstr ""
#: app/views/admin/artwork_step_images/new.rhtml:1
msgid "New Artwork Step"
msgstr ""
#: app/views/admin/artwork_step_images/new.rhtml:5
#: app/views/admin/artwork_placement_reasons/new.rhtml:5
#: app/views/admin/artwork_materials/new.rhtml:5
#: app/views/admin/techniques/new.rhtml:5
#: app/views/admin/artwork_conditions/new.rhtml:5
#: app/views/admin/artwork_sets/new.rhtml:5
#: app/views/admin/artwork_sizes/new.rhtml:5
#: app/views/admin/artworks/new.rhtml:5
#: app/views/admin/artwork_groups/new.rhtml:5
msgid "Add"
msgstr ""
#: app/views/admin/artwork_step_images/index.rhtml:1
msgid "Steps in Artwork '%s'"
msgstr ""
......
#: app/views/admin/artwork_step_images/_form.rhtml:7
#: app/views/admin/artworks/show.rhtml:37
#: app/views/admin/artworks/_form.rhtml:36
#: app/views/admin/artworks/_form.rhtml:37
msgid "Date:"
msgstr ""
......
msgid "Modify Artwork Step"
msgstr ""
#: app/views/admin/users/index.rhtml:1
msgid "Not implemented yet !"
msgstr ""
#: app/views/admin/artwork_placement_reasons/new.rhtml:1
msgid "New Artwork Placement Reason"
msgstr ""
......
msgid "Steps"
msgstr ""
#: app/views/admin/artworks/index.rhtml:20
#: app/views/admin/artworks/index.rhtml:24
#: app/views/admin/artworks/show.rhtml:49
msgid "View Steps"
msgstr ""
......
msgstr ""
#: app/views/admin/artworks/show.rhtml:12
#: app/views/admin/artworks/_form.rhtml:10
#: app/views/admin/artworks/_form.rhtml:11
msgid "General"
msgstr ""
......
msgstr ""
#: app/views/admin/artworks/show.rhtml:28
#: app/views/admin/artworks/_form.rhtml:25
#: app/views/admin/artworks/_form.rhtml:26
msgid "Size:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:29
#: app/views/admin/artworks/_form.rhtml:27
#: app/views/admin/artworks/_form.rhtml:28
msgid "Material:"
msgstr ""
......
msgstr ""
#: app/views/admin/artworks/show.rhtml:32
#: app/views/admin/artworks/_form.rhtml:30
#: app/views/admin/artworks/_form.rhtml:31
msgid "Result"
msgstr ""
#: app/views/admin/artworks/show.rhtml:33
#: app/views/admin/artworks/_form.rhtml:31
#: app/views/admin/artworks/_form.rhtml:32
msgid "Condition:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:34
#: app/views/admin/artworks/_form.rhtml:32
#: app/views/admin/artworks/_form.rhtml:33
msgid "Placement"
msgstr ""
#: app/views/admin/artworks/show.rhtml:35
#: app/views/admin/artworks/_form.rhtml:33
#: app/views/admin/artworks/_form.rhtml:34
msgid "Reason:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:36
#: app/views/admin/artworks/_form.rhtml:35
#: app/views/admin/artworks/_form.rhtml:36
msgid "Location:"
msgstr ""
......
msgid "View all Steps"
msgstr ""
#: app/views/admin/artworks/_form.rhtml:11
#: app/views/admin/artworks/_form.rhtml:12
msgid "Title:"
msgstr ""
#: app/views/admin/artworks/_form.rhtml:12
#: app/views/admin/artworks/_form.rhtml:13
msgid "Set:"
msgstr ""
#: app/views/admin/artworks/_form.rhtml:14
#: app/views/admin/artworks/_form.rhtml:15
msgid "Position into Artwork Set:"
msgstr ""
#: app/views/admin/artworks/_form.rhtml:15
#: app/views/admin/artworks/_form.rhtml:16
msgid "Group:"
msgstr ""
#: app/views/admin/artworks/_form.rhtml:22
#: app/views/admin/artworks/_form.rhtml:23
msgid "Position into Artwork Group:"
msgstr ""
#: app/views/admin/artworks/_form.rhtml:28
#: app/views/admin/artworks/_form.rhtml:29
msgid "Techniques"
msgstr ""
po/fr/MyCyma.po
msgid ""
msgstr ""
"Project-Id-Version: MyCyma 0.1.0\n"
"POT-Creation-Date: 2008-09-18 23:59+0200\n"
"POT-Creation-Date: 2008-11-28 00:31+0100\n"
"PO-Revision-Date: 2008-07-28 02:17+0200\n"
"Last-Translator: Marc Dequènes (Duck) <Duck@DuckCorp.org>\n"
"MIME-Version: 1.0\n"
......
msgid "ArtworkGroup|Comment"
msgstr "Ensemble|Commentaire"
#: app/models/user.rb:-
msgid "user"
msgstr "utilisateur"
#: app/models/user.rb:-
msgid "User|Login"
msgstr "Utilisateur|Identifiant"
#: app/models/user.rb:-
msgid "User|Real name"
msgstr "Utilisateur|Nom"
#: app/models/user.rb:-
msgid "User|Email"
msgstr "Utilisateur|Email"
#: app/models/user.rb:-
msgid "User|Hashed password"
msgstr "Utilisateur|Mot de passe haché"
#: app/models/user.rb:-
msgid "User|Salt"
msgstr "Utilisateur|Sel"
#: app/models/user.rb:-
msgid "User|Created at"
msgstr "Utilisateur|Créé le :"
#: app/models/user.rb:-
msgid "User|Updated at"
msgstr "Utilisateur|Mis à jour le :"
#: app/models/user.rb:-
msgid "User|Admin"
msgstr "Utilisateur|Admin"
#: app/models/user.rb:11
msgid "Invalid email"
msgstr "Email invalide"
#: app/models/artwork_condition.rb:-
msgid "artwork condition"
msgstr "état de l'œuvre"
......
msgid "New %s"
msgstr "Nouveau/Nouvelle %s"
#: app/helpers/application_helper.rb:126
#: app/views/admin/artwork_step_images/new.rhtml:5
#: app/views/admin/artwork_placement_reasons/new.rhtml:5
#: app/views/admin/artwork_materials/new.rhtml:5
#: app/views/admin/techniques/new.rhtml:5
#: app/views/admin/artwork_conditions/new.rhtml:5
#: app/views/admin/artwork_sets/new.rhtml:5
#: app/views/admin/artwork_sizes/new.rhtml:5
#: app/views/admin/artworks/new.rhtml:5
#: app/views/admin/artwork_groups/new.rhtml:5
msgid "Add"
msgstr "Ajouter"
#: app/helpers/application_helper.rb:128
msgid "Cancel"
msgstr "Annuler"
......
msgid "Updated at:"
msgstr "Mis(e) à jour le :"
#: app/controllers/application.rb:40
msgid "Please login to continue"
msgstr "Veuillez vous identifier pour continuer"
#: app/controllers/logon_controller.rb:9
msgid "Login successful"
msgstr "Identification réussie"
#: app/controllers/logon_controller.rb:12
msgid "Login unsuccessful"
msgstr "Identification échouée"
#: app/views/welcome/index.rhtml:1
msgid "ArtBook Manager"
msgstr "Gestionnaire de Livre d'Art"
......
msgid "Latest 10 Artworks"
msgstr "10 Dernières Œuvres"
#: app/views/layouts/application.rhtml:20
#: app/views/layouts/application.rhtml:24
msgid "Setup the Cyma"
msgstr "Gérer la Cimaise"
#: app/views/layouts/application.rhtml:22
#: app/views/layouts/application.rhtml:26
msgid "Manage Artworks"
msgstr "Gérer les Œuvres"
#: app/views/layouts/application.rhtml:23
#: app/views/layouts/application.rhtml:27
msgid "Manage Artwork Conditions"
msgstr "Gérer les États des Œuvres"
#: app/views/layouts/application.rhtml:24
#: app/views/layouts/application.rhtml:28
msgid "Manage Artwork Materials"
msgstr "Gérer les Matériaux des Œuvres"
#: app/views/layouts/application.rhtml:25
#: app/views/layouts/application.rhtml:29
msgid "Manage Artwork Placement Reasons"
msgstr "Gérer les Raisons de Placement des Œuvres"
#: app/views/layouts/application.rhtml:26
#: app/views/layouts/application.rhtml:30
msgid "Manage Artwork Sets & Groups"
msgstr "Gérer les Séries et les Ensembles d'Œuvres"
#: app/views/layouts/application.rhtml:27
#: app/views/layouts/application.rhtml:31
msgid "Manage Artwork Sizes"
msgstr "Gérer les Dimensions des Œuvres"
#: app/views/layouts/application.rhtml:28
#: app/views/layouts/application.rhtml:32
msgid "Manage Techniques"
msgstr "Gérer les Techniques"
#: app/views/layouts/application.rhtml:31
#: app/views/layouts/application.rhtml:35
msgid "Manage Users"
msgstr "Gérer les Utilisateurs"
#: app/views/layouts/application.rhtml:40
msgid "About"
msgstr "À Propos"
#: app/views/layouts/application.rhtml:33
#: app/views/layouts/application.rhtml:42
msgid "Project page"
msgstr "Page du Projet"
#: app/views/layouts/application.rhtml:34
#: app/views/layouts/application.rhtml:43
msgid "Help"
msgstr "Aide"
#: app/views/layouts/application.rhtml:48
msgid "Loggued in as '%s'"
msgstr "Identifié en '%s'"
#: app/views/layouts/application.rhtml:49
msgid "Not loggued in"
msgstr "Non identifié"
#: app/views/admin/artwork_step_images/new.rhtml:1
msgid "New Artwork Step"
msgstr "Nouvelle Étape de l'Œuvre"
#: app/views/admin/artwork_step_images/new.rhtml:5
#: app/views/admin/artwork_placement_reasons/new.rhtml:5
#: app/views/admin/artwork_materials/new.rhtml:5
#: app/views/admin/techniques/new.rhtml:5
#: app/views/admin/artwork_conditions/new.rhtml:5
#: app/views/admin/artwork_sets/new.rhtml:5
#: app/views/admin/artwork_sizes/new.rhtml:5
#: app/views/admin/artworks/new.rhtml:5
#: app/views/admin/artwork_groups/new.rhtml:5
msgid "Add"
msgstr "Ajouter"
#: app/views/admin/artwork_step_images/index.rhtml:1
msgid "Steps in Artwork '%s'"
msgstr "Étapes de l'Œuvre '%s'"
......
#: app/views/admin/artwork_step_images/_form.rhtml:7
#: app/views/admin/artworks/show.rhtml:37
#: app/views/admin/artworks/_form.rhtml:36
#: app/views/admin/artworks/_form.rhtml:37
msgid "Date:"
msgstr "Date "
......
msgid "Modify Artwork Step"
msgstr "Modifier l'Étape de l'Œuvre"
#: app/views/admin/users/index.rhtml:1
msgid "Not implemented yet !"
msgstr "Pas encore implémenté !"
#: app/views/admin/artwork_placement_reasons/new.rhtml:1
msgid "New Artwork Placement Reason"
msgstr "Nouvelle Raison de Placement d'une Œuvre"
......
msgid "Steps"
msgstr "Étapes"
#: app/views/admin/artworks/index.rhtml:20
#: app/views/admin/artworks/index.rhtml:24
#: app/views/admin/artworks/show.rhtml:49
msgid "View Steps"
msgstr "Voir les Étapes"
......
msgstr "Œuvre '%s'"
#: app/views/admin/artworks/show.rhtml:12
#: app/views/admin/artworks/_form.rhtml:10
#: app/views/admin/artworks/_form.rhtml:11
msgid "General"
msgstr "Général"
......
msgstr "Série / Ensemble :"
#: app/views/admin/artworks/show.rhtml:28
#: app/views/admin/artworks/_form.rhtml:25
#: app/views/admin/artworks/_form.rhtml:26
msgid "Size:"
msgstr "Dimensions :"
#: app/views/admin/artworks/show.rhtml:29
#: app/views/admin/artworks/_form.rhtml:27
#: app/views/admin/artworks/_form.rhtml:28
msgid "Material:"
msgstr "Matériau :"
......
msgstr "Techniques :"
#: app/views/admin/artworks/show.rhtml:32
#: app/views/admin/artworks/_form.rhtml:30
#: app/views/admin/artworks/_form.rhtml:31
msgid "Result"
msgstr "Résultat"
#: app/views/admin/artworks/show.rhtml:33
#: app/views/admin/artworks/_form.rhtml:31
#: app/views/admin/artworks/_form.rhtml:32
msgid "Condition:"
msgstr "État :"
#: app/views/admin/artworks/show.rhtml:34
#: app/views/admin/artworks/_form.rhtml:32
#: app/views/admin/artworks/_form.rhtml:33
msgid "Placement"
msgstr "Placement"
#: app/views/admin/artworks/show.rhtml:35
#: app/views/admin/artworks/_form.rhtml:33
#: app/views/admin/artworks/_form.rhtml:34
msgid "Reason:"
msgstr "Raison :"
#: app/views/admin/artworks/show.rhtml:36
#: app/views/admin/artworks/_form.rhtml:35
#: app/views/admin/artworks/_form.rhtml:36
msgid "Location:"
msgstr "Lieu :"
......
msgid "View all Steps"
msgstr "Voir toutes les Étapes"
#: app/views/admin/artworks/_form.rhtml:11
#: app/views/admin/artworks/_form.rhtml:12
msgid "Title:"
msgstr "Titre :"
#: app/views/admin/artworks/_form.rhtml:12
#: app/views/admin/artworks/_form.rhtml:13
msgid "Set:"
msgstr "Série :"
#: app/views/admin/artworks/_form.rhtml:14
#: app/views/admin/artworks/_form.rhtml:15
msgid "Position into Artwork Set:"
msgstr "Position dans la Série :"
#: app/views/admin/artworks/_form.rhtml:15
#: app/views/admin/artworks/_form.rhtml:16
msgid "Group:"
msgstr "Ensemble :"
#: app/views/admin/artworks/_form.rhtml:22
#: app/views/admin/artworks/_form.rhtml:23
msgid "Position into Artwork Group:"
msgstr "Position dans l'Ensemble :"
#: app/views/admin/artworks/_form.rhtml:28
#: app/views/admin/artworks/_form.rhtml:29
msgid "Techniques"
msgstr "techniques"

Also available in: Unified diff