Commit 9e2094cb authored by Hermann Mayer's avatar Hermann Mayer

[User Management] Added devise for user management and customized views and application.

parent 2de2f8f5
......@@ -37,5 +37,6 @@ gem 'jquery-rails'
# To use debugger
# gem 'debugger'
gem "twitter-bootstrap-rails", "~> 2.2.4"
gem 'twitter-bootstrap-rails', '~> 2.2.4'
gem 'devise'
......@@ -29,6 +29,7 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.4)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
......@@ -36,7 +37,12 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.5.0)
coffee-script-source (1.6.1)
devise (2.2.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
......@@ -54,6 +60,7 @@ GEM
mime-types (1.21)
multi_json (1.6.1)
mysql2 (0.3.11)
orm_adapter (0.4.0)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
......@@ -95,20 +102,23 @@ GEM
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
twitter-bootstrap-rails (2.2.4)
twitter-bootstrap-rails (2.2.6)
actionpack (>= 3.1)
execjs
railties (>= 3.1)
tzinfo (0.3.35)
tzinfo (0.3.36)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
warden (1.2.1)
rack (>= 1.0)
PLATFORMS
ruby
DEPENDENCIES
coffee-rails (~> 3.2.1)
devise
jquery-rails
mysql2
rails (= 3.2.12)
......
jQuery ->
$("a[rel=popover]").popover()
$('*[rel=popover]').popover()
$(".tooltip").tooltip()
$("a[rel=tooltip]").tooltip()
\ No newline at end of file
$("a[rel=tooltip]").tooltip()
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
......@@ -93,3 +93,27 @@ padding: 0;
padding: 10px;
}
.glow > a {
color: #999999;
}
.glow > a:hover {
text-decoration: none;
color: #0088CC;
}
.nav .dropdown .dropdown-menu {
left: 43px;
}
.dropdown .dropdown-menu > li {
display: block;
float: none;
width: auto;
}
.dropdown .dropdown-menu > li > a {
font-weight: normal;
text-align: left;
}
// Place all the styles related to the User controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class UsersController < ApplicationController
# GET /users
# GET /users.json
def index
respond_to do |format|
format.html # index.html.erb
format.json { render json: @teams }
end
end
end
module UserHelper
end
module UsersHelper
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
end
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>
<div><%= f.submit "Resend confirmation instructions" %></div>
<% end %>
<%= render "devise/shared/links" %>
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
<% if user_signed_in? %>
<li>
<%= link_to destroy_user_session_path, :method => :delete do %>
<i class="icon-off icon-white"></i> Ausloggen
<% end %>
</li>
<% else %>
<li>
<%= link_to new_user_session_path do %>
<i class="icon-share-alt icon-white"></i> Einloggen
<% end %>
</li>
<% end %>
<% if user_signed_in? %>
<li>
<%= link_to edit_user_registration_path do %>
<i class="icon-edit icon-white"></i> Profil bearbeiten
<% end %>
</li>
<% else %>
<li>
<%= link_to new_user_registration_path do %>
<i class="icon-asterisk icon-white"></i> Registrieren
<% end %>
</li>
<% end %>
<h2>Change your password</h2>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div><%= f.label :password, "New password" %><br />
<%= f.password_field :password, :autofocus => true %></div>
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.submit "Change my password" %></div>
<% end %>
<%= render "devise/shared/links" %>
<h2>Passwort vergessen?</h2>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, :class => "form-horizontal" }) do |f| %>
<%= devise_error_messages! %>
<div class="control-group">
<%= f.label :email, :class => "control-label" %>
<div class="controls">
<%= f.email_field :email, :autofocus => true %>
</div>
</div>
<div class="control-group">
<div class="controls">
<%= f.submit 'Erneut Anweisungen senden', :class => "btn btn-primary" %>
</div>
</div>
<% end %>
<%= render "devise/shared/links" %>
<h2>Profil bearbeiten</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => "form-horizontal" }) do |f| %>
<%= devise_error_messages! %>
<div class="control-group">
<%= f.label :email, :class => "control-label" %>
<div class="controls">
<%= f.email_field :email, :autofocus => true %>
</div>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Warte im Moment auf Bestätigung für: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="control-group">
<%= f.label :password, :class => "control-label" %>
<div class="controls">
<%= f.password_field :password, :autocomplete => "off",
:data => {
:content => "Kann leer gelassen werden, wenn man das Passwort nicht ändern möchte.",
:"original-title" => "Hinweis",
:trigger => "focus",
},
:rel => "popover"
%>
</div>
</div>
<div class="control-group">
<%= f.label :password_confirmation, :class => "control-label" %>
<div class="controls">
<%= f.password_field :password_confirmation %>
</div>
</div>
<div class="control-group">
<%= f.label :current_password, :class => "control-label" %>
<div class="controls">
<%= f.password_field :current_password,
:data => {
:content => "Das aktuelle Passwort wird für diese Änderung benötigt.",
:"original-title" => "Hinweis",
:trigger => "focus",
},
:rel => "popover"
%>
</div>
</div>
<div class="control-group">
<div class="controls">
<%= f.submit 'Aktualisieren', :class => "btn btn-primary" %>
</div>
</div>
<% end %>
<h3>Mitgliedschaft beenden</h3>
<%= button_to "Profil löschen", registration_path(resource_name), :data => { :confirm => "Bist du sicher?" }, :method => :delete, :class => 'btn btn-danger' %>
<%= link_to :back, :class => 'btn' do %>
<i class="icon-share-alt icon-white"></i> Zurück
<% end %>
<h2>Als Mitglied registrieren</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form-horizontal"} ) do |f| %>
<%= devise_error_messages! %>
<div class="control-group">
<%= f.label :email, :class => "control-label" %>
<div class="controls">
<%= f.email_field :email, :autofocus => true %>
</div>
</div>
<div class="control-group">
<%= f.label :password, :class => "control-label" %>
<div class="controls">
<%= f.password_field :password %>
</div>
</div>
<div class="control-group">
<%= f.label :password_confirmation, :class => "control-label" %>
<div class="controls">
<%= f.password_field :password_confirmation %>
</div>
</div>
<div class="control-group">
<div class="controls">
<%= f.submit 'Anmelden', :class => "btn btn-primary" %>
</div>
</div>
<% end %>
<%= render "devise/shared/links" %>
<h2>Als Mitglied anmelden</h2>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => "form-horizontal"} ) do |f| %>
<div class="control-group">
<%= f.label :email, :class => "control-label" %>
<div class="controls">
<%= f.email_field :email, :autofocus => true %>
</div>
</div>
<div class="control-group">
<%= f.label :password, :class => "control-label" %>
<div class="controls">
<%= f.password_field :password %>
</div>
</div>
<div class="control-group">
<div class="controls">
<% if devise_mapping.rememberable? -%>
<label class="checkbox">
<input type="checkbox"> Angemeldet bleiben
</label>
<% end -%>
<%= f.submit 'Einloggen', :class => "btn btn-primary" %>
</div>
</div>
<% end %>
<%= render "devise/shared/links" %>
<%- if controller_name != 'sessions' %>
<%= link_to new_session_path(resource_name), :class => 'btn' do %>
<i class="icon-share-alt icon-white"></i> Einloggen
<% end %>
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to new_registration_path(resource_name), :class => 'btn' do %>
<i class="icon-asterisk icon-white"></i> Registrieren
<% end %>
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to new_password_path(resource_name), :class => 'btn' do %>
<i class="icon-question-sign icon-white"></i> Passwort vergessen?
<% end %>
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to new_confirmation_path(resource_name), :class => 'btn' do %>
<i class="icon-question-sign icon-white"></i> Bestätigungsmail nicht erhalten?
<% end %>
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to new_unlock_path(resource_name), :class => 'btn' do %>
<i class="icon-question-sign icon-white"></i> Freischaltmail nicht erhalten?
<% end %>
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to omniauth_authorize_path(resource_name, provider), :class => 'btn' do %>
<i class="icon-share-alt icon-white"></i> Einloggen mit <%= provider.to_s.titleize %>
<% end %>
<% end -%>
<% end -%>
<h2>Resend unlock instructions</h2>
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>
<div><%= f.submit "Resend unlock instructions" %></div>
<% end %>
<%= render "devise/shared/links" %>
......@@ -9,7 +9,7 @@
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" type="text/javascript"></script>
<![endif]-->
<%= stylesheet_link_tag "application", :media => "all" %>
......@@ -39,35 +39,44 @@
<div class="container" id="theaser">
<div class="masthead">
<h3 class="muted glow">KickerTracker</h3>
<h3 class="muted glow">
<%= link_to 'KickerTracker', :controller => "/application" %>
</h3>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li class="<%= 'active' if params[:controller] == 'application' and params[:action] == 'index' %>">
<%= link_to :controller => "application" do %>
<i class="icon icon-home"></i> Home
<% end %>
<li class="dropdown <%= 'active' if params[:controller] == 'users' or params[:controller] =~ /devise/ %>">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
<i class="icon icon-hand-right"></i> Mitmachen
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<%= render 'devise/menu/registration_items' %>
<%= render 'devise/menu/login_items' %>
</ul>
</li>
<li class="<%= 'active' if params[:controller] == 'teams' %>">
<%= link_to :controller => "teams" do %>
<i class="icon icon-th-large"></i> Teams
<% end %>
<%= link_to :controller => "/teams" do %>
<i class="icon icon-th-large"></i> Teams
<% end %>
</li>
<li class="<%= 'active' if params[:controller] == 'players' %>">
<%= link_to :controller => "players" do %>
<i class="icon icon-user"></i> Spieler
<% end %>
<%= link_to :controller => "/players" do %>
<i class="icon icon-user"></i> Spieler
<% end %>
</li>
<li class="<%= 'active' if params[:controller] == 'matches' %>">
<%= link_to :controller => "matches" do %>
<i class="icon icon-flag"></i> Matches
<% end %>
<%= link_to :controller => "/matches" do %>
<i class="icon icon-flag"></i> Matches
<% end %>
</li>
<li class="<%= 'active' if params[:controller] == 'application' and params[:action] == 'about' %>">
<%= link_to :controller => "application", :action => "about" do %>
<i class="icon icon-info-sign"></i> Über das Projekt
<% end %>
<%= link_to :controller => "/application", :action => "about" do %>
<i class="icon icon-info-sign"></i> Über das Projekt
<% end %>
</li>
</ul>
</div>
......
......@@ -3,8 +3,10 @@
<div>
<h2 class="">
Matches Auflistung
<%= link_to new_match_path, :class => "btn btn-primary pull-right" do %>
<i class="icon-pencil icon-white"></i> Neues Match anlegen
<% if user_signed_in? %>
<%= link_to new_match_path, :class => "btn btn-primary pull-right" do %>
<i class="icon-pencil icon-white"></i> Neues Match anlegen
<% end %>
<% end %>
</h2>
</div>
......@@ -18,24 +20,26 @@
<th>Operationen</th>
</tr>
<% @matches.each do |match| %>
<tr>
<td><%= match.date %></td>
<td><%= link_to match.teamA.name, match.teamA %></td>
<td><%= link_to match.teamB.name, match.teamB %></td>
<td><%= link_to match.winner.name, match.winner %></td>
<td>
<%= link_to match, :class => "btn" do %>
<i class="icon-search icon-white"></i> Anzeigen
<% end %>
<%= link_to edit_match_path(match), :class => "btn btn-primary" do %>
<i class="icon-edit icon-white"></i> Bearbeiten
<% end %>
<%= link_to match, method: :delete, data: { confirm: 'Bist du sicher?' }, :class => "btn btn-danger" do %>
<i class="icon-remove icon-white"></i> Löschen
<% end %>
</td>
</tr>
<% end %>
<% @matches.each do |match| %>
<tr>
<td><%= match.date %></td>
<td><%= link_to match.teamA.name, match.teamA %></td>
<td><%= link_to match.teamB.name, match.teamB %></td>
<td><%= link_to match.winner.name, match.winner %></td>
<td>
<%= link_to match, :class => "btn" do %>
<i class="icon-search icon-white"></i> Anzeigen
<% end %>
<% if user_signed_in? %>
<%= link_to edit_match_path(match), :class => "btn btn-primary" do %>
<i class="icon-edit icon-white"></i> Bearbeiten
<% end %>
<%= link_to match, method: :delete, data: { confirm: 'Bist du sicher?' }, :class => "btn btn-danger" do %>
<i class="icon-remove icon-white"></i> Löschen
<% end %>
<% end %>
</td>
</tr>
<% end %>
</table>
<h2>Matchdetails</h2>
<p>
<b>Datum:</b>
<%= @match.date %>
<b>Datum:</b>
<%= @match.date %>
</p>
<p>
<b>Team A:</b>
<%= link_to(@match.teamA.name, @match.teamA) %>
<b>Team A:</b>
<%= link_to(@match.teamA.name, @match.teamA) %>
</p>
<p>
<b>Team B:</b>
<%= link_to(@match.teamB.name, @match.teamB) %>
<b>Team B:</b>
<%= link_to(@match.teamB.name, @match.teamB) %>
</p>
<p>
<b>Gewinner:</b>
<%= link_to(@match.winner.name, @match.winner) %>
<b>Gewinner:</b>
<%= link_to(@match.winner.name, @match.winner) %>
</p>
<%= link_to edit_match_path(@match), :class => "btn" do %>
<i class="icon-edit icon-white"></i> Bearbeiten
<% if user_signed_in? %>
<%= link_to edit_match_path(@match), :class => "btn" do %>
<i class="icon-edit icon-white"></i> Bearbeiten
<% end %>
<% end %>
<%= link_to matches_path, :class => "btn" do %>
......
<div>
<h2 class="">
Spieler Auflistung
<%= link_to new_player_path, :class => "btn btn-primary pull-right" do %>
<i class="icon-pencil icon-white"></i> Neuen Spieler anlegen
<% if user_signed_in? %>
<%= link_to new_player_path, :class => "btn btn-primary pull-right" do %>
<i class="icon-pencil icon-white"></i> Neuen Spieler anlegen
<% end %>
<% end %>
</h2>
</div>
......@@ -14,22 +16,24 @@
<th>Operationen</th>
</tr>
<% @players.each do |player| %>
<tr>
<td><%= player.name %></td>
<td><%= player.team.blank? ? 'Keinem Team zugeordnet' : link_to(player.team.name, player.team) %></td>
<td>
<%= link_to player, :class => "btn" do %>
<i class="icon-search icon-white"></i> Anzeigen
<% end %>
<%= link_to edit_player_path(player), :class => "btn btn-primary" do %>
<i class="icon-edit icon-white"></i> Bearbeiten
<% end %>
<%= link_to player, method: :delete, data: { confirm: 'Bist du sicher?' }, :class => "btn btn-danger" do %>
<i class="icon-remove icon-white"></i> Löschen
<% end %>
</td>
</tr>
<% end %>
<% @players.each do |player| %>
<tr>
<td><%= player.name %></td>
<td><%= player.team.blank? ? 'Keinem Team zugeordnet' : link_to(player.team.name, player.team) %></td>
<td>
<%= link_to player, :class => "btn" do %>
<i class="icon-search icon-white"></i> Anzeigen
<% end %>
<% if user_signed_in? %>
<%= link_to edit_player_path(player), :class => "btn btn-primary" do %>
<i class="icon-edit icon-white"></i> Bearbeiten
<% end %>
<%= link_to player, method: :delete, data: { confirm: 'Bist du sicher?' }, :class => "btn btn-danger" do %>
<i class="icon-remove icon-white"></i> Löschen
<% end %>
<% end %>
</td>
</tr>
<% end %>
</table>
<h2>Spielerdetails</h2>
<p>
<b>Name:</b>
<%= @player.name %>
<b>Name:</b>
<%= @player.name %>
</p>
<p>
<b>Team:</b>
<%= @player.team.blank? ? 'Keinem Team zugeordnet' : link_to(@player.team.name, @player.team) %>
<b>Team:</b>
<%= @player.team.blank? ? 'Keinem Team zugeordnet' : link_to(@player.team.name, @player.team) %>
</p>
<%= link_to edit_player_path(@player), :class => "btn" do %>
<i class="icon-edit icon-white"></i> Bearbeiten
<% if user_signed_in? %>
<%= link_to edit_player_path(@player), :class => "btn" do %>
<i class="icon-edit icon-white"></i> Bearbeiten
<% end %>
<% end %>
<%= link_to players_path, :class => "btn" do %>
......