Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added twitter validation (avatar_type) and removed signup button disable

  • Loading branch information...
commit 7e20f44381a8ab79f48b3b3a17b98414db11f2d1 1 parent 91df17c
Ryan Jones authored
View
44 app/assets/javascripts/members/devise_styles.js.coffee
@@ -1,15 +1,5 @@
$ ->
# email - validation
- # disable signup button before ajax call
- $("#member_email").bind('ajax:before', (evt, data, status, xhr) ->
- $("input[type=submit]").attr("disabled", "disabled")
- )
-
- # enable signup button after ajax call
- $("#member_email").bind('ajax:complete', (evt, data, status, xhr) ->
- $("input[type=submit]").removeAttr("disabled")
- )
-
# apply css class based on result
$("#member_email").bind('ajax:success', (evt, data, status, xhr) ->
if (data is false)
@@ -31,17 +21,6 @@ $ ->
)
# twitter - validation
-
- # disable signup button before ajax call
- $("#member_twitter").bind('ajax:before', (evt, data, status, xhr) ->
- $("input[type=submit]").attr("disabled", "disabled")
- )
-
- # enable signup button after ajax call
- $("#member_twitter").bind('ajax:complete', (evt, data, status, xhr) ->
- $("input[type=submit]").removeAttr("disabled")
- )
-
$("#member_twitter").bind('ajax:success', (evt, data, status, xhr) ->
if (data is false)
$('#twitter_check').html('Invalid twitter username.')
@@ -61,18 +40,7 @@ $ ->
$('#member_twitter').removeClass("pass")
)
- # github - validation
-
- # disable signup button before ajax call
- $("#member_github").bind('ajax:before', (evt, data, status, xhr) ->
- $("input[type=submit]").attr("disabled", "disabled")
- )
-
- # enable signup button after ajax call
- $("#member_github").bind('ajax:complete', (evt, data, status, xhr) ->
- $("input[type=submit]").removeAttr("disabled")
- )
-
+ # github - validation
$("#member_github").bind('ajax:success', (evt, data, status, xhr) ->
if (data is false)
$('#github_check').html('Invalid github username.')
@@ -93,16 +61,6 @@ $ ->
)
# blogrss - validation
-
- # disable signup button before ajax call
- $("#member_blogrss").bind('ajax:before', (evt, data, status, xhr) ->
- $("input[type=submit]").attr("disabled", "disabled")
- )
-
- # enable signup button after ajax call
- $("#member_blogrss").bind('ajax:complete', (evt, data, status, xhr) ->
- $("input[type=submit]").removeAttr("disabled")
- )
$("#member_blogrss").bind('ajax:success', (evt, data, status, xhr) ->
if (data is false)
$('#blogrss_check').html('Invalid blog url.')
View
7 app/controllers/registrations_controller.rb
@@ -32,6 +32,13 @@ def update
# update member
if @member.update_attributes(params[:member])
+
+ # delete avatar if it exists to keep db clean
+ unless @member.avatar.nil?
+ avatar = member.avatar
+ avatar.delete
+ end
+
# the member has passed validation so we need to save their avatar
create_member_avatar(params[:member][:avatar_type], @member)
View
7 app/models/member.rb
@@ -14,6 +14,7 @@ class Member < ActiveRecord::Base
validate :twitter_check
validate :github_check
validate :blogrss_check
+ validate :avatar_check
has_many :tweets, :dependent => :destroy
has_many :git_events, :dependent => :destroy
@@ -68,5 +69,9 @@ def blogrss_check
end
end
-
+ def avatar_check
+ if avatar_type == "Twitter" && twitter.empty?
+ errors.add :base, "You must have a twitter username to set as your profile image."
+ end
+ end
end
View
5 todo.txt
@@ -1,13 +1,10 @@
== RJ ==
-- Loading gifs during ajax calls (ajax:loading)
- Style devise pages (ie: field_with_errors)
-- Check user display pic exists with field entered (ie Twitter need a twitter username)
- Clean up garbage avatars
== MG ==
-
--------------------------------- TODO ---------------------------------
- Add more Jasmine tests
- Ability to delete users (or let users delete themselves from Edit), removing all their feed items
@@ -23,6 +20,7 @@
- Display "in reply to" on Tweets
- Make whole system config driven (so other people can implement it for themselves)
- Display avatars so people know which one they're picking
+- Loading gifs during ajax calls (ajax:loading)
--------------------------------- COMPLETED ---------------------------------
===== Release 1.0 =====
@@ -42,3 +40,4 @@
- Design header
- replace profile links with proper images
- make profile link images display conditional on values present
+- Check user display pic exists with field entered (ie Twitter need a twitter username)
Please sign in to comment.
Something went wrong with that request. Please try again.