Fix the whole devise and admins and everythings

This commit is contained in:
Tom Naessens 2014-12-09 20:34:50 +01:00
parent 539d491115
commit dc6d0b5d21
10 changed files with 100 additions and 103 deletions

View file

@ -31,38 +31,17 @@ $gray-medium-light: #eaeaea;
/* miscellaneous */
.debug_dump {
clear: both;
float: left;
width: 100%;
margin-top: 45px;
@include box_sizing;
.nowrap {
white-space: nowrap;
}
/* forms */
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
margin-bottom: 15px;
@include box_sizing;
}
input {
height: auto !important;
}
/* boostrap */
body {
padding-top: 80px;
}
/* footer */
footer {
margin-top: 45px;
padding-top: 5px;
@ -105,7 +84,6 @@ footer ul li {
font-weight: bold;
font-size: 24px;
}
.overview{

View file

@ -0,0 +1,21 @@
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t('errors.messages.not_saved',
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
html = <<-HTML
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Error!</strong> #{sentence}
#{messages}
</div>
HTML
html.html_safe
end
end

View file

@ -1,22 +1,16 @@
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= 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 class="field">
<%= f.label :password, "New password" %><br />
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>
<div><%= f.label :password, "New password" %><br />
<%= f.password_field :password, :autofocus => true %></div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation %></div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<div><%= f.submit "Change my password" %></div>
<% end %>
<%= render "devise/shared/links" %>

View file

@ -1,16 +1,10 @@
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<%= form_email_field f, :email %>
<%= f.submit "Send me reset password instructions", class: "btn btn-primary" %>
<% end %>
<%= render "devise/shared/links" %>

View file

@ -1,28 +1,16 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<%= form_text_field f, :nickname %>
<%= form_text_field f, :name %>
<%= form_text_field f, :last_name %>
<%= form_password_field f, :password %>
<%= form_password_field f, :password_confirmation %>
<%= form_password_field f, :current_password %>
<div class="actions">
<%= f.submit "Update" %>
</div>
<%= f.submit "Update", class: 'btn btn-primary' %>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>

View file

@ -11,7 +11,7 @@
<%= form_password_field f, :password_confirmation %>
<div class="actions">
<%= f.submit "Sign up" %>
<%= f.submit "Sign up", class: 'btn btn-primary' %>
</div>
<% end %>

View file

@ -1,24 +1,16 @@
<h2>Log in</h2>
<%= render partial: 'flash' %>
<h2>Sign in</h2>
<div class="alert alert-info">Partners sign in using the link sent by email.</div>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<%= form_text_field f, :nickname %>
<%= form_password_field f, :password %>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<% if devise_mapping.rememberable? %>
<%= form_check_box f, :remember_me %>
<% end %>
<% if devise_mapping.rememberable? -%>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<div class="actions">
<%= f.submit "Log in" %>
</div>
<%= f.submit "Sign in", class: "btn btn-primary" %>
<% end %>
<%= render "devise/shared/links" %>

View file

@ -0,0 +1,25 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<% end -%>
<% if devise_mapping.registerable? && controller_name != 'registrations' %>
<% link_to "Sign up", new_registration_path(resource_name) %>
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>

View file

@ -4,8 +4,8 @@
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
<%= f.label :nickname %><br />
<%= f.email_field :nickname, autofocus: true %>
</div>
<div class="actions">

View file

@ -11,47 +11,52 @@
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<div class="collapse navbar-collapse">
<div class="hidden-xs navbar-form navbar-right">
<div class="form-group">
<% if user_signed_in? %>
<%= button_to "Logout", destroy_user_session_path(current_user), class: "btn btn-default form-control", method: :delete %>
<%= button_to "Logout", destroy_user_session_path, class: "btn btn-default form-control", method: :delete %>
<% else %>
<%= button_to "Login", new_user_session_path, class: "btn btn-success form-control" %>
<%= link_to "Login", new_user_session_path, class: "btn btn-success form-control" %>
<%= link_to "Register", new_user_registration_path, class: "btn btn-default form-control" %>
<% end %>
</div>
</div>
<ul class="nav navbar-nav navbar-right">
<li><%= mail_to "tab@zeus.ugent.be", "Send feedback" %></li>
<% if can? :manage, :all %>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Products <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><%= link_to "All products", products_path %></li>
<li><%= link_to "New product" , new_product_path %></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Users <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><%= link_to "index" , users_path %></li>
</ul>
</li>
<% end %>
<% if user_signed_in? %>
<li>
<a>Logged in as <%= current_user.display_name %></a>
</li>
<% if can? :manage, :all %>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Products <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><%= link_to "All products", products_path %></li>
<li><%= link_to "New product" , new_product_path %></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Users <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><%= link_to "index" , users_path %></li>
</ul>
</li>
<% end %>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Logged in as <%= current_user.nickname %> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><%= link_to "Edit password", edit_user_registration_path %></li>
</ul>
</li>
<% end %>
</ul>
<div class="visible-xs navbar-form">
<div class="form-group">
<% if user_signed_in? %>
<%= button_to "Logout", destroy_user_session_path(current_user), class: "btn btn-default form-control", method: :delete %>
<%= button_to "Logout", destroy_user_session_path, class: "btn btn-default form-control", method: :delete %>
<% else %>
<%= button_to "Login", new_user_session_path, class: "btn btn-success form-control" %>
<%= link_to "Login", new_user_session_path, class: "btn btn-success form-control" %>
<%= link_to "Register", new_user_registration_path, class: "btn btn-default form-control" %>
<% end %>
</div>
</div>