-
Notifications
You must be signed in to change notification settings - Fork 5
WIP: Update to Python 3 and modern Django #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d9de38b
Python 3 update: First draft version
garw ad2d2ef
Reformat code with black
garw 91e002b
Fix invoice creation
garw 1c41475
Fix MEDIA_ROOT usage
garw 55d1e1d
Fix RT functionality
garw 1cbae0c
Remove old site-local config example
garw 8e712b9
Fix TokenAuthenticationBackend
garw a111bb0
Fix case typo for template loaders
garw 7a071b9
Pin to Django 3
bernharddick 16bf139
Fix defective URL entry
bernharddick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,4 +1,8 @@ | ||||||
The complete software part and website templates is licensed under the MIT License (see below). | ||||||
However, we use the python rt module that is licensed und GPLv3. As a consequence, this whole | ||||||
project is distributed under the terms of the GPLv3 even though all SaBot code itself is lisenced | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
under the terms of the MIT License. If you want to use it under these terms, either disable the RT | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
support on the code or provide an alternative implementation in sabot/rt.py. | ||||||
|
||||||
This license does not apply to | ||||||
- Sample invoice and offer documents provided in invoice/ | ||||||
|
This file contains hidden or 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,35 +1,36 @@ | ||
import models | ||
from django.contrib.auth.models import User | ||
|
||
|
||
class TokenAuthenticationBackend(object): | ||
supports_inactive_user = False | ||
supports_inactive_user = False | ||
|
||
def authenticate(self, token=None): | ||
if token is None or len(token) == 0: | ||
return None | ||
try: | ||
profile = models.UserProfile.objects.get(authToken__iexact=token) | ||
return profile.user | ||
except models.UserProfile.DoesNotExist: | ||
return None | ||
def authenticate(self, token=None): | ||
if token is None or len(token) == 0: | ||
return None | ||
try: | ||
profile = models.UserProfile.objects.get(authToken__iexact=token) | ||
return profile.user | ||
except models.UserProfile.DoesNotExist: | ||
return None | ||
|
||
def get_user(self, user_id): | ||
try: | ||
return User.objects.get(pk=user_id) | ||
except User.DoesNotExist: | ||
return None | ||
|
||
def get_user(self, user_id): | ||
try: | ||
return User.objects.get(pk=user_id) | ||
except User.DoesNotExist: | ||
return None | ||
|
||
class APITokenMiddleware(object): | ||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
|
||
def __call__(self, request): | ||
try: | ||
token = request.META.get("HTTP_TOKEN") | ||
if token is not None: | ||
profile = models.UserProfile.objects.get(authToken__iexact=token) | ||
request.user = profile.user | ||
except models.UserProfile.DoesNotExist: | ||
pass | ||
return self.get_response(request) | ||
def __call__(self, request): | ||
try: | ||
token = request.META.get("HTTP_TOKEN") | ||
if token is not None: | ||
profile = models.UserProfile.objects.get(authToken__iexact=token) | ||
request.user = profile.user | ||
except models.UserProfile.DoesNotExist: | ||
pass | ||
return self.get_response(request) |
This file contains hidden or 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,50 +1,51 @@ | ||
from registration.forms import RegistrationFormUniqueEmail | ||
from django import forms | ||
from django.contrib.auth.models import User | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
from django_registration.forms import RegistrationFormUniqueEmail | ||
from captcha.fields import ReCaptchaField | ||
from crispy_forms.helper import FormHelper | ||
from crispy_forms.layout import Layout, Field, Submit, Div, HTML | ||
from crispy_forms.bootstrap import FormActions, StrictButton, TabHolder, Tab | ||
|
||
|
||
class RegistrationFormNameAndUniqueEmail(RegistrationFormUniqueEmail): | ||
class Meta(RegistrationFormUniqueEmail.Meta): | ||
fields = [ | ||
'username', | ||
'first_name', | ||
'last_name', | ||
'email', | ||
'password1', | ||
'password2' | ||
] | ||
required_css_class = 'required' | ||
class Meta(RegistrationFormUniqueEmail.Meta): | ||
fields = [ | ||
User.USERNAME_FIELD, | ||
User.get_email_field_name(), | ||
"first_name", | ||
"last_name", | ||
"password1", | ||
"password2", | ||
] | ||
required_css_class = "required" | ||
|
||
captcha = ReCaptchaField() | ||
captcha = ReCaptchaField() | ||
|
||
|
||
class UserProfileForm(forms.Form): | ||
firstName = forms.CharField(max_length=64,label=_("First name")) | ||
lastName = forms.CharField(max_length=64,label=_("Last name")) | ||
email = forms.EmailField(max_length=75,label=_("E-mail")) | ||
firstName = forms.CharField(max_length=64, label=_("First name")) | ||
lastName = forms.CharField(max_length=64, label=_("Last name")) | ||
email = forms.EmailField(max_length=75, label=_("E-mail")) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(UserProfileForm, self).__init__(*args, **kwargs) | ||
self.helper = FormHelper() | ||
self.helper.add_input(Submit("Save","Save")) | ||
def __init__(self, *args, **kwargs): | ||
super(UserProfileForm, self).__init__(*args, **kwargs) | ||
self.helper = FormHelper() | ||
self.helper.add_input(Submit("Save", "Save")) | ||
|
||
|
||
class SetPasswordForm(forms.Form): | ||
password1 = forms.CharField(widget=forms.PasswordInput, label=_("Password")) | ||
password2 = forms.CharField(widget=forms.PasswordInput, label=_("Password (again)")) | ||
|
||
def clean(self): | ||
if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data: | ||
if self.cleaned_data['password1'] != self.cleaned_data['password2']: | ||
raise forms.ValidationError(_("The two password fields didn't match.")) | ||
return self.cleaned_data | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(SetPasswordForm, self).__init__(*args, **kwargs) | ||
self.helper = FormHelper() | ||
self.helper.add_input(Submit("submit","Set password")) | ||
password1 = forms.CharField(widget=forms.PasswordInput, label=_("Password")) | ||
password2 = forms.CharField(widget=forms.PasswordInput, label=_("Password (again)")) | ||
|
||
def clean(self): | ||
if "password1" in self.cleaned_data and "password2" in self.cleaned_data: | ||
if self.cleaned_data["password1"] != self.cleaned_data["password2"]: | ||
raise forms.ValidationError(_("The two password fields didn't match.")) | ||
return self.cleaned_data | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(SetPasswordForm, self).__init__(*args, **kwargs) | ||
self.helper = FormHelper() | ||
self.helper.add_input(Submit("submit", "Set password")) |
This file contains hidden or 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
This file contains hidden or 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,8 +1,9 @@ | ||
from django.db import models | ||
from django.contrib.auth.models import User | ||
from django.db.models.signals import post_save | ||
|
||
class UserProfile(models.Model): | ||
user = models.OneToOneField(User, related_name="legacy_profile") | ||
authToken = models.CharField(max_length=64, null=True) | ||
|
||
class UserProfile(models.Model): | ||
user = models.OneToOneField( | ||
User, related_name="legacy_profile", on_delete=models.CASCADE | ||
) | ||
authToken = models.CharField(max_length=64, null=True) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.