Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix line endings in a very large number of files.
- Loading branch information
1 parent
fd1155e
commit 98accf3
Showing
53 changed files
with
2,613 additions
and
2,613 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from django.contrib import admin | ||
|
||
from twobuntu.accounts.models import Profile | ||
|
||
admin.site.register(Profile) | ||
from django.contrib import admin | ||
|
||
from twobuntu.accounts.models import Profile | ||
|
||
admin.site.register(Profile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import PasswordResetForm, UserCreationForm | ||
from django.contrib.auth.models import User | ||
|
||
from twobuntu.accounts.models import Profile | ||
from twobuntu.captcha.fields import CaptchaField | ||
|
||
|
||
class RegistrationForm(UserCreationForm): | ||
""" | ||
Form for new user registrations. | ||
""" | ||
|
||
email = forms.EmailField(help_text="Used for account verification and password resets.") | ||
captcha = CaptchaField() | ||
|
||
|
||
class ResetForm(PasswordResetForm): | ||
""" | ||
Form for resetting a user's password. | ||
""" | ||
|
||
email = forms.EmailField(help_text="Email address used when registering.") | ||
|
||
def clean_email(self): | ||
""" | ||
Verify that the email address is valid. | ||
""" | ||
try: | ||
self.user = User.objects.get(email=self.cleaned_data['email'], is_active=True) | ||
except User.DoesNotExist: | ||
raise forms.ValidationError("The email address provided does not match an active account.") | ||
|
||
|
||
class ProfileForm(forms.ModelForm): | ||
""" | ||
Form for editing a user's profile. | ||
""" | ||
|
||
first_name = forms.CharField( | ||
max_length=30, | ||
required=False, | ||
help_text="First name [optional].", | ||
) | ||
last_name = forms.CharField( | ||
max_length=30, | ||
required=False, | ||
help_text="Last name [optional].", | ||
) | ||
email = forms.EmailField(help_text="Used for account verification and password resets.") | ||
|
||
class Meta: | ||
model = Profile | ||
fields = ('first_name', 'last_name', 'email', 'birthday', 'location', 'website', 'bio') | ||
from django import forms | ||
from django.contrib.auth.forms import PasswordResetForm, UserCreationForm | ||
from django.contrib.auth.models import User | ||
|
||
from twobuntu.accounts.models import Profile | ||
from twobuntu.captcha.fields import CaptchaField | ||
|
||
|
||
class RegistrationForm(UserCreationForm): | ||
""" | ||
Form for new user registrations. | ||
""" | ||
|
||
email = forms.EmailField(help_text="Used for account verification and password resets.") | ||
captcha = CaptchaField() | ||
|
||
|
||
class ResetForm(PasswordResetForm): | ||
""" | ||
Form for resetting a user's password. | ||
""" | ||
|
||
email = forms.EmailField(help_text="Email address used when registering.") | ||
|
||
def clean_email(self): | ||
""" | ||
Verify that the email address is valid. | ||
""" | ||
try: | ||
self.user = User.objects.get(email=self.cleaned_data['email'], is_active=True) | ||
except User.DoesNotExist: | ||
raise forms.ValidationError("The email address provided does not match an active account.") | ||
|
||
|
||
class ProfileForm(forms.ModelForm): | ||
""" | ||
Form for editing a user's profile. | ||
""" | ||
|
||
first_name = forms.CharField( | ||
max_length=30, | ||
required=False, | ||
help_text="First name [optional].", | ||
) | ||
last_name = forms.CharField( | ||
max_length=30, | ||
required=False, | ||
help_text="Last name [optional].", | ||
) | ||
email = forms.EmailField(help_text="Used for account verification and password resets.") | ||
|
||
class Meta: | ||
model = Profile | ||
fields = ('first_name', 'last_name', 'email', 'birthday', 'location', 'website', 'bio') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,88 @@ | ||
from django.contrib.auth.models import User | ||
from django.db import models | ||
from django.dispatch import receiver | ||
from django.template.defaultfilters import slugify | ||
from django.utils.encoding import python_2_unicode_compatible | ||
from django.utils.timezone import now | ||
|
||
from twobuntu.utils import uuid | ||
|
||
|
||
@python_2_unicode_compatible | ||
class Profile(models.Model): | ||
""" | ||
Information about an author. | ||
""" | ||
|
||
user = models.OneToOneField( | ||
User, | ||
primary_key=True, | ||
) | ||
birthday = models.DateField( | ||
blank=True, | ||
null=True, | ||
help_text="Birthday in YYYY-MM-DD format [used for displaying age].", | ||
) | ||
location = models.CharField( | ||
max_length=40, | ||
blank=True, | ||
help_text="Geographic location.", | ||
) | ||
website = models.URLField( | ||
blank=True, | ||
help_text="A personal blog or website.", | ||
) | ||
bio = models.TextField( | ||
blank=True, | ||
help_text="A brief biography.", | ||
) | ||
|
||
def __str__(self): | ||
return self.user.get_full_name() or self.user.get_username() | ||
|
||
@models.permalink | ||
def get_absolute_url(self): | ||
kwargs, slug = {'id': self.user.id}, slugify(self) | ||
if slug: | ||
kwargs['slug'] = slug | ||
return ('accounts:profile', (), kwargs) | ||
|
||
def age(self): | ||
""" | ||
Calculate the age of the user. | ||
""" | ||
if not self.birthday: | ||
return None | ||
n, b = now().date(), self.birthday | ||
return n.year - b.year - (0 if n.month > b.month or n.month == b.month and n.day >= b.day else 1) | ||
|
||
class Meta: | ||
ordering = ('-user__last_login',) | ||
|
||
|
||
@receiver(models.signals.post_save, sender=User) | ||
def create_profile(instance, created, **kwargs): | ||
""" | ||
Create a profile whenever a user is created. | ||
""" | ||
if created: | ||
Profile.objects.create(user=instance) | ||
|
||
|
||
@python_2_unicode_compatible | ||
class ConfirmationKey(models.Model): | ||
""" | ||
Unique token for confirming a user account or resetting a password. | ||
""" | ||
|
||
user = models.OneToOneField( | ||
User, | ||
primary_key=True, | ||
) | ||
key = models.CharField( | ||
max_length=32, | ||
default=uuid, | ||
) | ||
|
||
def __str__(self): | ||
return self.user | ||
from django.contrib.auth.models import User | ||
from django.db import models | ||
from django.dispatch import receiver | ||
from django.template.defaultfilters import slugify | ||
from django.utils.encoding import python_2_unicode_compatible | ||
from django.utils.timezone import now | ||
|
||
from twobuntu.utils import uuid | ||
|
||
|
||
@python_2_unicode_compatible | ||
class Profile(models.Model): | ||
""" | ||
Information about an author. | ||
""" | ||
|
||
user = models.OneToOneField( | ||
User, | ||
primary_key=True, | ||
) | ||
birthday = models.DateField( | ||
blank=True, | ||
null=True, | ||
help_text="Birthday in YYYY-MM-DD format [used for displaying age].", | ||
) | ||
location = models.CharField( | ||
max_length=40, | ||
blank=True, | ||
help_text="Geographic location.", | ||
) | ||
website = models.URLField( | ||
blank=True, | ||
help_text="A personal blog or website.", | ||
) | ||
bio = models.TextField( | ||
blank=True, | ||
help_text="A brief biography.", | ||
) | ||
|
||
def __str__(self): | ||
return self.user.get_full_name() or self.user.get_username() | ||
|
||
@models.permalink | ||
def get_absolute_url(self): | ||
kwargs, slug = {'id': self.user.id}, slugify(self) | ||
if slug: | ||
kwargs['slug'] = slug | ||
return ('accounts:profile', (), kwargs) | ||
|
||
def age(self): | ||
""" | ||
Calculate the age of the user. | ||
""" | ||
if not self.birthday: | ||
return None | ||
n, b = now().date(), self.birthday | ||
return n.year - b.year - (0 if n.month > b.month or n.month == b.month and n.day >= b.day else 1) | ||
|
||
class Meta: | ||
ordering = ('-user__last_login',) | ||
|
||
|
||
@receiver(models.signals.post_save, sender=User) | ||
def create_profile(instance, created, **kwargs): | ||
""" | ||
Create a profile whenever a user is created. | ||
""" | ||
if created: | ||
Profile.objects.create(user=instance) | ||
|
||
|
||
@python_2_unicode_compatible | ||
class ConfirmationKey(models.Model): | ||
""" | ||
Unique token for confirming a user account or resetting a password. | ||
""" | ||
|
||
user = models.OneToOneField( | ||
User, | ||
primary_key=True, | ||
) | ||
key = models.CharField( | ||
max_length=32, | ||
default=uuid, | ||
) | ||
|
||
def __str__(self): | ||
return self.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{% autoescape off %}Hello {{ user.profile }}, | ||
Thank you for deciding to create an account on 2buntu. In order to complete the registration process, we need you to complete one more step. Please open the URL below in your browser: | ||
{{ url }} | ||
If you are unable to click the link, please copy and paste it into your browser's address bar. | ||
- The 2buntu Staff{% endautoescape %} | ||
{% autoescape off %}Hello {{ user.profile }}, | ||
|
||
Thank you for deciding to create an account on 2buntu. In order to complete the registration process, we need you to complete one more step. Please open the URL below in your browser: | ||
|
||
{{ url }} | ||
|
||
If you are unable to click the link, please copy and paste it into your browser's address bar. | ||
|
||
- The 2buntu Staff{% endautoescape %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{% autoescape off %}Hello {{ user.profile }}, | ||
Someone has begun the password reset procedure on your account. If this was you, please open the URL below in your browser: | ||
{{ url }} | ||
If you are unable to click the link, please copy and paste it into your browser's address bar. | ||
If you did not initiate this procedure, please ignore this email. | ||
- The 2buntu Staff{% endautoescape %} | ||
{% autoescape off %}Hello {{ user.profile }}, | ||
|
||
Someone has begun the password reset procedure on your account. If this was you, please open the URL below in your browser: | ||
|
||
{{ url }} | ||
|
||
If you are unable to click the link, please copy and paste it into your browser's address bar. | ||
|
||
If you did not initiate this procedure, please ignore this email. | ||
|
||
- The 2buntu Staff{% endautoescape %} |
48 changes: 24 additions & 24 deletions
48
twobuntu/accounts/templates/accounts/fragments/authors.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
<h2>Meet the Authors</h2> | ||
<p> | ||
We have a number of different authors that contribute articles to our blog. | ||
Each of them writes with a unique perspective, ensuring that we have a diverse collection articles accessible to anyone. | ||
</p> | ||
<br> | ||
{% if users %} | ||
<div class="row"> | ||
{% for user in users|slice:":6" %} | ||
{% if forloop.counter0 == 3 %} | ||
</div> | ||
<br> | ||
<div class="row"> | ||
{% endif %} | ||
<div class="col-sm-4 text-center"> | ||
{% include "accounts/fragments/author.html" %} | ||
</div> | ||
{% endfor %} | ||
</div> | ||
{% else %} | ||
<p class="text-muted"> | ||
There are currently no registered users. | ||
</p> | ||
{% endif %} | ||
<h2>Meet the Authors</h2> | ||
<p> | ||
We have a number of different authors that contribute articles to our blog. | ||
Each of them writes with a unique perspective, ensuring that we have a diverse collection articles accessible to anyone. | ||
</p> | ||
<br> | ||
{% if users %} | ||
<div class="row"> | ||
{% for user in users|slice:":6" %} | ||
{% if forloop.counter0 == 3 %} | ||
</div> | ||
<br> | ||
<div class="row"> | ||
{% endif %} | ||
<div class="col-sm-4 text-center"> | ||
{% include "accounts/fragments/author.html" %} | ||
</div> | ||
{% endfor %} | ||
</div> | ||
{% else %} | ||
<p class="text-muted"> | ||
There are currently no registered users. | ||
</p> | ||
{% endif %} |
Oops, something went wrong.