mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-16 08:31:36 -04:00
Merge pull request #21 from spacemunkay/denney-new-user-form
Denney new user form
This commit is contained in:
@@ -12,5 +12,4 @@
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require twitter/bootstrap
|
||||
//= require_tree .
|
||||
//= require custom_netzke_helpers
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
$(document).ready(function(){
|
||||
var MIN_LEN = 3;
|
||||
var MAX_SUBMITS = 3;
|
||||
var submit_count = 0;
|
||||
$("input[name=commit]").click( function(e){
|
||||
console.log("clicked");
|
||||
submit_count += 1;
|
||||
//IDs of contact info
|
||||
var contact_info_ids = [
|
||||
"user_email",
|
||||
"user_user_profiles_attributes_0_addrStreet1",
|
||||
"user_user_profiles_attributes_0_addrCity",
|
||||
"user_user_profiles_attributes_0_addrState",
|
||||
"user_user_profiles_attributes_0_addrZip",
|
||||
"user_user_profiles_attributes_0_phone"
|
||||
];
|
||||
var contact_vals = "";
|
||||
var index = 0;
|
||||
//see if any contact info exists
|
||||
for( var index in contact_info_ids){
|
||||
contact_vals += $("#"+contact_info_ids[index]).val();
|
||||
}
|
||||
if( contact_vals.length >= MIN_LEN || submit_count > MAX_SUBMITS){
|
||||
|
||||
if( submit_count > MAX_SUBMITS ){
|
||||
alert("Fine.");
|
||||
}
|
||||
return true;
|
||||
|
||||
}else{
|
||||
|
||||
switch(submit_count){
|
||||
case 1:
|
||||
alert("It appears you have not entered any contact information. " +
|
||||
"Please do.");
|
||||
break;
|
||||
case 2:
|
||||
alert("It is highly recommended that you enter at least one form of" +
|
||||
" contact information. It is in your best interest.");
|
||||
break;
|
||||
case 3:
|
||||
alert("If something happens to your bicycle, we will not be able to" +
|
||||
" notify you. Please enter at least one form of contact.");
|
||||
break;
|
||||
default:
|
||||
alert("Please enter at least one form of contact.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@ class AppTabPanel < Netzke::Basepack::TabPanel
|
||||
|
||||
action :sign_out do |c|
|
||||
c.icon = :door_out
|
||||
c.text = "Sign out #{controller.current_user.email}" if controller.current_user
|
||||
c.text = "Exit"
|
||||
end
|
||||
|
||||
action :check_out do |c|
|
||||
|
||||
@@ -4,6 +4,7 @@ class UserStats < Netzke::Base
|
||||
bike = user.bike
|
||||
%Q(
|
||||
<div id="user_stats_page">
|
||||
<p>Username: #{user.username}</p>
|
||||
<p>Total Hours Worked: #{user.total_hours}</p>
|
||||
<p>Hours worked in #{Time.now.strftime('%B')}: #{user.current_month_hours}</p>
|
||||
<p>Current bike Shop ID: #{bike.shop_id if bike}</p>
|
||||
|
||||
@@ -5,6 +5,7 @@ class Users < Netzke::Basepack::Grid
|
||||
c.model = "User"
|
||||
|
||||
c.columns = [
|
||||
:username,
|
||||
:first_name,
|
||||
:last_name,
|
||||
:nickname,
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
module DeviseHelper
|
||||
# A simple way to show error messages for the current devise resource. If you need
|
||||
# to customize this method, you can either overwrite it in your application helpers or
|
||||
# copy the views to your application.
|
||||
#
|
||||
# This method is intended to stay simple and it is unlikely that we are going to change
|
||||
# it to add more behavior or options.
|
||||
def devise_error_messages!
|
||||
return "" if resource.errors.empty?
|
||||
|
||||
messages = resource.errors.full_messages.map { |msg| content_tag(:p, msg, :class => "alert") }.join
|
||||
sentence = I18n.t("errors.messages.not_saved",
|
||||
:count => resource.errors.count,
|
||||
:resource => resource.class.model_name.human.downcase)
|
||||
|
||||
html = <<-HTML
|
||||
<p>#{sentence}</p>
|
||||
#{messages}
|
||||
HTML
|
||||
|
||||
html.html_safe
|
||||
end
|
||||
end
|
||||
+5
-1
@@ -8,7 +8,7 @@ class User < ActiveRecord::Base
|
||||
# Setup accessible (or protected) attributes for your model
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me,
|
||||
:first_name, :last_name, :nickname, :bike_id,
|
||||
:user_profiles_attributes
|
||||
:user_profiles_attributes, :username
|
||||
|
||||
has_many :transactions
|
||||
has_many :user_profiles
|
||||
@@ -26,6 +26,10 @@ class User < ActiveRecord::Base
|
||||
"#{first_name} #{last_name}"
|
||||
end
|
||||
|
||||
def email_required?
|
||||
false
|
||||
end
|
||||
|
||||
def full_name
|
||||
to_s
|
||||
end
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
class UserProfile < ActiveRecord::Base
|
||||
# Setup accessible (or protected) attributes for your model
|
||||
attr_accessible :user_id, :addrStreet1, :addrStreet2, :addrCity,
|
||||
:addrState, :addrZip, :phone
|
||||
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :bike
|
||||
|
||||
#validates :addrStreet1 , :presence => true
|
||||
#validates :addrCity , :presence => true
|
||||
#validates :addrState , :presence => true
|
||||
#validates :addrZip , :presence => true
|
||||
validates :phone, :presence => true
|
||||
#validates :addrStreet1 , :presence => true
|
||||
#validates :addrCity , :presence => true
|
||||
#validates :addrState , :presence => true
|
||||
#validates :addrZip , :presence => true
|
||||
#validates :phone, :presence => true
|
||||
|
||||
def to_s
|
||||
[addrStreet1, addrStreet2, addrCity, addrState, addrZip, phone].join(" - ")
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
= stylesheet_link_tag "bootstrap_and_overrides", :media => "all"
|
||||
%h2 Sign up
|
||||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
||||
= devise_error_messages!
|
||||
%div
|
||||
= f.label :username
|
||||
%br/
|
||||
= f.text_field :username
|
||||
%div
|
||||
= f.label :first_name
|
||||
%br/
|
||||
@@ -18,7 +23,8 @@
|
||||
%br/
|
||||
= f.email_field :email
|
||||
%div
|
||||
= f.fields_for :user_profiles, UserProfile.new do |builder|
|
||||
- profile_builder = resource.user_profiles.empty? ? resource.user_profiles.build : resource.user_profiles
|
||||
= f.fields_for :user_profiles, profile_builder do |builder|
|
||||
= render 'user_profile_fields', f: builder
|
||||
%div
|
||||
= f.label :password
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<h2>Velocipede</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
<div><%= f.label :username%><br />
|
||||
<%= f.text_field :username%></div>
|
||||
|
||||
<div><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
@@ -28,9 +28,9 @@
|
||||
<% if Rails.env.development? %>
|
||||
<% User.all.each do |user| %>
|
||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||
<%= f.hidden_field :email, :value => user.email %></div>
|
||||
<%= f.hidden_field :username, :value => user.username%></div>
|
||||
<%= f.hidden_field :password, :value => 'password' %></div>
|
||||
<div><%= f.submit "Sign in as #{user.email}" %></div>
|
||||
<div><%= f.submit "Sign in as #{user.username}" %></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -28,3 +28,4 @@
|
||||
%p © Velocipede 2013
|
||||
|
||||
= javascript_include_tag "application"
|
||||
= javascript_include_tag params[:controller]
|
||||
|
||||
Reference in New Issue
Block a user