mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-05 16:49:45 +00:00
Adding static signup page.
This commit is contained in:
parent
2455bb7b15
commit
3bd8c56e71
6 changed files with 86 additions and 3 deletions
|
@ -2,7 +2,9 @@ import stripe
|
||||||
import datetime
|
import datetime
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.views.decorators.http import require_POST
|
from django.views.decorators.http import require_POST
|
||||||
|
from django.views.decorators.csrf import csrf_protect
|
||||||
from django.contrib.auth import logout as logout_user
|
from django.contrib.auth import logout as logout_user
|
||||||
|
from django.contrib.auth import login as login_user
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
@ -16,6 +18,7 @@ from apps.profile.models import Profile, PaymentHistory, RNewUserQueue
|
||||||
from apps.reader.models import UserSubscription, UserSubscriptionFolders
|
from apps.reader.models import UserSubscription, UserSubscriptionFolders
|
||||||
from apps.profile.forms import StripePlusPaymentForm, PLANS, DeleteAccountForm
|
from apps.profile.forms import StripePlusPaymentForm, PLANS, DeleteAccountForm
|
||||||
from apps.profile.forms import ForgotPasswordForm, ForgotPasswordReturnForm, AccountSettingsForm
|
from apps.profile.forms import ForgotPasswordForm, ForgotPasswordReturnForm, AccountSettingsForm
|
||||||
|
from apps.reader.forms import SignupForm
|
||||||
from apps.social.models import MSocialServices, MActivity, MSocialProfile
|
from apps.social.models import MSocialServices, MActivity, MSocialProfile
|
||||||
from utils import json_functions as json
|
from utils import json_functions as json
|
||||||
from utils.user_functions import ajax_login_required
|
from utils.user_functions import ajax_login_required
|
||||||
|
@ -77,6 +80,24 @@ def get_preference(request):
|
||||||
response = dict(code=code, payload=payload)
|
response = dict(code=code, payload=payload)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@csrf_protect
|
||||||
|
def signup(request):
|
||||||
|
form = SignupForm()
|
||||||
|
|
||||||
|
if request.method == "POST":
|
||||||
|
form = SignupForm(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")
|
||||||
|
new_user.profile.activate_free()
|
||||||
|
return HttpResponseRedirect(request.POST['next'])
|
||||||
|
|
||||||
|
return render_to_response('accounts/signup.html', {
|
||||||
|
'form': form,
|
||||||
|
'next': request.REQUEST.get('next', "")
|
||||||
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
@ajax_login_required
|
@ajax_login_required
|
||||||
@require_POST
|
@require_POST
|
||||||
@json.json_view
|
@json.json_view
|
||||||
|
|
|
@ -77,7 +77,7 @@ class SignupForm(forms.Form):
|
||||||
'invalid': "Your username may only contain letters and numbers."
|
'invalid': "Your username may only contain letters and numbers."
|
||||||
})
|
})
|
||||||
email = forms.EmailField(widget=forms.TextInput(attrs={'maxlength': 75, 'class': 'NB-input'}),
|
email = forms.EmailField(widget=forms.TextInput(attrs={'maxlength': 75, 'class': 'NB-input'}),
|
||||||
label=_(u'email address'),
|
label=_(u'email'),
|
||||||
required=True,
|
required=True,
|
||||||
error_messages={'required': 'Please enter an email.'})
|
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'}),
|
||||||
|
|
|
@ -10225,7 +10225,7 @@ form.opml_import_form input {
|
||||||
margin: 24px auto;
|
margin: 24px auto;
|
||||||
}
|
}
|
||||||
.NB-static-login .NB-static-form {
|
.NB-static-login .NB-static-form {
|
||||||
width: 360px;
|
width: 320px;
|
||||||
}
|
}
|
||||||
.NB-static-oauth .NB-static-form-label label {
|
.NB-static-oauth .NB-static-form-label label {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
|
@ -10259,7 +10259,11 @@ form.opml_import_form input {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
.NB-static-form-alttext {
|
||||||
|
margin: 24px 0 0 120px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px solid rgba(0, 0, 0, .1);
|
||||||
|
}
|
||||||
|
|
||||||
/* ======================== */
|
/* ======================== */
|
||||||
/* = Feed Options Popover = */
|
/* = Feed Options Popover = */
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
<input type="submit" value="login" class="NB-modal-submit-button NB-modal-submit-green NB-static-form-submit" />
|
<input type="submit" value="login" class="NB-modal-submit-button NB-modal-submit-green NB-static-form-submit" />
|
||||||
<input type="hidden" name="next" value="{{ next }}" />
|
<input type="hidden" name="next" value="{{ next }}" />
|
||||||
|
<p class="NB-static-form-alttext"><a href="{% url "signup" %}?next={{ next }}">Create an account</a></a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
55
templates/accounts/signup.html
Normal file
55
templates/accounts/signup.html
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% load typogrify_tags utils_tags zebra_tags %}
|
||||||
|
|
||||||
|
{% block bodyclass %}NB-static NB-static-oauth NB-static-login{% endblock %}
|
||||||
|
{% block extra_head_js %}
|
||||||
|
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("input[name=username]").focus();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% include_stylesheets "common" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}Create an Account{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="NB-static-title">
|
||||||
|
Create an Account
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="NB-static-form-wrapper" style="overflow:hidden">
|
||||||
|
<form method="post" class="NB-static-form" action="{% url "signup" %}">
|
||||||
|
{% if form.errors %}
|
||||||
|
{% if form.errors.username %}
|
||||||
|
<p class="NB-error error">{{ form.errors.username.as_text }}</p>
|
||||||
|
{% else %}{% if form.errors.email %}
|
||||||
|
<p class="NB-error error">{{ form.errors.email.as_text }}</p>
|
||||||
|
{% else %}
|
||||||
|
<p class="NB-error error">{{ form.non_field_errors.as_text }}</p>
|
||||||
|
{% endif %}{% endif %}
|
||||||
|
{% else %}{% if next %}
|
||||||
|
<p class="NB-error error">Please create an account to continue.</p>
|
||||||
|
{% endif %}{% endif %}
|
||||||
|
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="NB-static-form-label">{{ form.username.label_tag }}</div>
|
||||||
|
<div class="NB-static-form-input">{{ form.username }}</div>
|
||||||
|
<div class="NB-static-form-label">{{ form.password.label_tag }}</div>
|
||||||
|
<div class="NB-static-form-input">{{ form.password }}</div>
|
||||||
|
<div class="NB-static-form-label">{{ form.email.label_tag }}</div>
|
||||||
|
<div class="NB-static-form-input">{{ form.email }}</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 }}">Login to your account</a></a>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
2
urls.py
2
urls.py
|
@ -3,6 +3,7 @@ from django.conf import settings
|
||||||
from apps.reader import views as reader_views
|
from apps.reader import views as reader_views
|
||||||
from apps.social import views as social_views
|
from apps.social import views as social_views
|
||||||
from apps.static import views as static_views
|
from apps.static import views as static_views
|
||||||
|
from apps.profile import views as profile_views
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
@ -53,6 +54,7 @@ urlpatterns = patterns('',
|
||||||
url(r'^account/login/?$',
|
url(r'^account/login/?$',
|
||||||
'django.contrib.auth.views.login',
|
'django.contrib.auth.views.login',
|
||||||
{'template_name': 'accounts/login.html'}, name='login'),
|
{'template_name': 'accounts/login.html'}, name='login'),
|
||||||
|
url(r'^account/signup/?$', profile_views.signup, name='signup'),
|
||||||
url(r'^account/logout/?$',
|
url(r'^account/logout/?$',
|
||||||
'django.contrib.auth.views.logout',
|
'django.contrib.auth.views.logout',
|
||||||
{'next_page': '/'}, name='logout'),
|
{'next_page': '/'}, name='logout'),
|
||||||
|
|
Loading…
Add table
Reference in a new issue