mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Merge branch 'master' into dejal
This commit is contained in:
commit
fde1f671d8
6 changed files with 64 additions and 30 deletions
|
@ -1,8 +1,9 @@
|
|||
import stripe
|
||||
import requests
|
||||
import datetime
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.views.decorators.http import require_POST
|
||||
from django.views.decorators.csrf import csrf_protect
|
||||
from django.views.decorators.csrf import csrf_protect, csrf_exempt
|
||||
from django.contrib.auth import logout as logout_user
|
||||
from django.contrib.auth import login as login_user
|
||||
from django.db.models.aggregates import Sum
|
||||
|
@ -101,13 +102,26 @@ def login(request):
|
|||
'next': request.REQUEST.get('next', "")
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@csrf_protect
|
||||
@csrf_exempt
|
||||
def signup(request):
|
||||
form = SignupForm()
|
||||
form = SignupForm(prefix="signup")
|
||||
recaptcha = request.POST.get('g-recaptcha-response', None)
|
||||
recaptcha_error = None
|
||||
|
||||
if not recaptcha:
|
||||
recaptcha_error = "Please hit the \"I'm not a robot\" button."
|
||||
else:
|
||||
response = requests.post('https://www.google.com/recaptcha/api/siteverify', {
|
||||
'secret': settings.RECAPTCHA_SECRET_KEY,
|
||||
'response': recaptcha,
|
||||
})
|
||||
result = response.json()
|
||||
if not result['success']:
|
||||
recaptcha_error = "Really, please hit the \"I'm not a robot\" button."
|
||||
|
||||
if request.method == "POST":
|
||||
form = SignupForm(data=request.POST)
|
||||
if form.is_valid():
|
||||
form = SignupForm(data=request.POST, prefix="signup")
|
||||
if form.is_valid() and not recaptcha_error:
|
||||
new_user = form.save()
|
||||
login_user(request, new_user)
|
||||
logging.user(new_user, "~FG~SB~BBNEW SIGNUP: ~FW%s" % new_user.email)
|
||||
|
@ -116,6 +130,7 @@ def signup(request):
|
|||
|
||||
return render_to_response('accounts/signup.html', {
|
||||
'form': form,
|
||||
'recaptcha_error': recaptcha_error,
|
||||
'next': request.REQUEST.get('next', "")
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
|
|
@ -88,7 +88,8 @@ class SignupForm(forms.Form):
|
|||
label=_(u'Email'),
|
||||
required=True,
|
||||
error_messages={'required': 'Please enter an email.'})
|
||||
password = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'NB-input'}),
|
||||
password = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'NB-input'},
|
||||
render_value=True,),
|
||||
label=_(u'Password'),
|
||||
required=False)
|
||||
# error_messages={'required': 'Please enter a password.'})
|
||||
|
@ -123,11 +124,13 @@ class SignupForm(forms.Form):
|
|||
username = self.cleaned_data.get('username', '')
|
||||
password = self.cleaned_data.get('password', '')
|
||||
email = self.cleaned_data.get('email', None)
|
||||
|
||||
exists = User.objects.filter(username__iexact=username).count()
|
||||
if exists:
|
||||
user_auth = authenticate(username=username, password=password)
|
||||
if not user_auth:
|
||||
raise forms.ValidationError(_(u'Someone is already using that username.'))
|
||||
|
||||
return self.cleaned_data
|
||||
|
||||
def save(self, profile_callback=None):
|
||||
|
|
|
@ -138,8 +138,10 @@ def welcome(request, **kwargs):
|
|||
login_form = LoginForm(request.POST, prefix='login')
|
||||
signup_form = SignupForm(prefix='signup')
|
||||
else:
|
||||
login_form = LoginForm(prefix='login')
|
||||
signup_form = SignupForm(request.POST, prefix='signup')
|
||||
return {
|
||||
"form": signup_form
|
||||
}, "accounts/signup.xhtml"
|
||||
else:
|
||||
login_form = LoginForm(prefix='login')
|
||||
signup_form = SignupForm(prefix='signup')
|
||||
|
@ -178,17 +180,22 @@ def login(request):
|
|||
return index(request)
|
||||
|
||||
@never_cache
|
||||
@render_to('accounts/signup.html')
|
||||
def signup(request):
|
||||
if request.method == "POST":
|
||||
form = SignupForm(prefix='signup', data=request.POST)
|
||||
if form.is_valid():
|
||||
new_user = form.save()
|
||||
login_user(request, new_user)
|
||||
logging.user(new_user, "~FG~SB~BBNEW SIGNUP: ~FW%s" % new_user.email)
|
||||
if not new_user.is_active:
|
||||
url = "https://%s%s" % (Site.objects.get_current().domain,
|
||||
reverse('stripe-form'))
|
||||
return HttpResponseRedirect(url)
|
||||
signup_form = SignupForm(request.POST, prefix='signup')
|
||||
return {
|
||||
"form": signup_form
|
||||
}
|
||||
# form = SignupForm(prefix='signup', data=request.POST)
|
||||
# if form.is_valid():
|
||||
# new_user = form.save()
|
||||
# login_user(request, new_user)
|
||||
# logging.user(new_user, "~FG~SB~BBNEW SIGNUP: ~FW%s" % new_user.email)
|
||||
# if not new_user.is_active:
|
||||
# url = "https://%s%s" % (Site.objects.get_current().domain,
|
||||
# reverse('stripe-form'))
|
||||
# return HttpResponseRedirect(url)
|
||||
|
||||
return index(request)
|
||||
|
||||
|
|
|
@ -3481,7 +3481,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = "Share Extension/Share Extension.entitlements";
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 105;
|
||||
CURRENT_PROJECT_VERSION = 107;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = HR7P97SD72;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
|
@ -3501,7 +3501,7 @@
|
|||
INFOPLIST_FILE = "Share Extension/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MARKETING_VERSION = 9.1;
|
||||
MARKETING_VERSION = 9.1.1;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.newsblur.NewsBlur.Share-Extension";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -3531,7 +3531,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = "Share Extension/Share Extension.entitlements";
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 105;
|
||||
CURRENT_PROJECT_VERSION = 107;
|
||||
DEVELOPMENT_TEAM = HR7P97SD72;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
|
@ -3545,7 +3545,7 @@
|
|||
INFOPLIST_FILE = "Share Extension/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MARKETING_VERSION = 9.1;
|
||||
MARKETING_VERSION = 9.1.1;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.newsblur.NewsBlur.Share-Extension";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -3566,7 +3566,7 @@
|
|||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 105;
|
||||
CURRENT_PROJECT_VERSION = 107;
|
||||
DEVELOPMENT_TEAM = HR7P97SD72;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3587,7 +3587,7 @@
|
|||
"\"$(SRCROOT)\"",
|
||||
"\"$(SRCROOT)/Other Sources\"",
|
||||
);
|
||||
MARKETING_VERSION = 9.1;
|
||||
MARKETING_VERSION = 9.1.1;
|
||||
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
|
||||
OTHER_LDFLAGS = (
|
||||
"-lsqlite3.0",
|
||||
|
@ -3616,7 +3616,7 @@
|
|||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
CURRENT_PROJECT_VERSION = 105;
|
||||
CURRENT_PROJECT_VERSION = 107;
|
||||
DEVELOPMENT_TEAM = HR7P97SD72;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3636,7 +3636,7 @@
|
|||
"\"$(SRCROOT)\"",
|
||||
"\"$(SRCROOT)/Other Sources\"",
|
||||
);
|
||||
MARKETING_VERSION = 9.1;
|
||||
MARKETING_VERSION = 9.1.1;
|
||||
OTHER_LDFLAGS = (
|
||||
"-lsqlite3.0",
|
||||
"-ObjC",
|
||||
|
@ -3757,7 +3757,7 @@
|
|||
CLANG_WARN_SUSPICIOUS_MOVES = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 105;
|
||||
CURRENT_PROJECT_VERSION = 107;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = HR7P97SD72;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
|
@ -3772,7 +3772,7 @@
|
|||
INFOPLIST_FILE = "Story Notification Service Extension/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MARKETING_VERSION = 9.1;
|
||||
MARKETING_VERSION = 9.1.1;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.newsblur.NewsBlur.Story-Notification-Service-Extension";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -3795,7 +3795,7 @@
|
|||
CLANG_WARN_SUSPICIOUS_MOVES = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 105;
|
||||
CURRENT_PROJECT_VERSION = 107;
|
||||
DEVELOPMENT_TEAM = HR7P97SD72;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
|
@ -3804,7 +3804,7 @@
|
|||
INFOPLIST_FILE = "Story Notification Service Extension/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MARKETING_VERSION = 9.1;
|
||||
MARKETING_VERSION = 9.1.1;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.newsblur.NewsBlur.Story-Notification-Service-Extension";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
.NB-static-form {
|
||||
margin: 0 auto;
|
||||
width: 360px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.NB-static-form input,
|
||||
|
@ -194,4 +193,8 @@
|
|||
}
|
||||
.NB-static-form input[name=plan] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.NB-static-form .g-recaptcha {
|
||||
padding-left: 120px;
|
||||
}
|
|
@ -24,6 +24,8 @@
|
|||
Create an Account
|
||||
</div>
|
||||
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
|
||||
<div class="NB-static-form-wrapper" style="overflow:hidden">
|
||||
<form method="post" class="NB-static-form" action="{% url "signup" %}">
|
||||
{% if form.errors %}
|
||||
|
@ -36,7 +38,9 @@
|
|||
{% endif %}{% endif %}
|
||||
{% else %}{% if next %}
|
||||
<p class="NB-error error">Please create an account to continue.</p>
|
||||
{% endif %}{% endif %}
|
||||
{% else %}{% if recaptcha_error %}
|
||||
<p class="NB-error error">{{ recaptcha_error }}</p>
|
||||
{% endif %}{% endif %}{% endif %}
|
||||
|
||||
{% csrf_token %}
|
||||
<div class="NB-static-form-label">{{ form.username.label_tag }}</div>
|
||||
|
@ -46,6 +50,8 @@
|
|||
<div class="NB-static-form-label">{{ form.email.label_tag }}</div>
|
||||
<div class="NB-static-form-input">{{ form.email }}</div>
|
||||
|
||||
<div class="g-recaptcha" data-sitekey="6LchVzcUAAAAAJH4uoEEhvoqgseZnEZC7LToC92E"></div>
|
||||
|
||||
<input type="submit" value="Sign Up" class="NB-modal-submit-button NB-modal-submit-green NB-static-form-submit" />
|
||||
<input type="hidden" name="next" value="{{ next }}" />
|
||||
<p class="NB-static-form-alttext"><a href="{% url "login" %}?next={{ next|urlencode }}">Login to your account</a></a>
|
||||
|
|
Loading…
Add table
Reference in a new issue