We planned to upgrade GitLab and Mattermost to the latest version this Friday morning. Expect some downtime!

Commit 3cdcafc8 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Lower case username in token API

parent 8c3c53e9
......@@ -8,13 +8,21 @@ from django.db.models import Q
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.utils.translation import gettext as _
from rest_framework.authtoken.views import ObtainAuthToken
from members.services import member_achievements
from members.models import Member
from .services import member_achievements
from . import models
from .forms import ProfileForm
class ObtainThaliaAuthToken(ObtainAuthToken):
def post(self, request, *args, **kwargs):
request._data = request.POST.copy()
request.POST['username'] = request.POST.get('username').lower()
return super().post(request, *args, **kwargs)
def filter_users(tab, keywords, year_range):
memberships_query = Q(until__gt=datetime.now()) | Q(until=None)
members_query = ~Q(id=None)
......@@ -54,7 +62,7 @@ def filter_users(tab, keywords, year_range):
memberships = models.Membership.objects.filter(memberships_query)
members_query &= Q(pk__in=memberships.values('user__pk'))
return (Member.objects
return (models.Member.objects
......@@ -112,7 +120,7 @@ def index(request):
def profile(request, pk=None):
if pk:
member = get_object_or_404(Member, pk=int(pk))
member = get_object_or_404(models.Member, pk=int(pk))
member = request.member
......@@ -165,11 +173,11 @@ def iban_export(request):
header_fields = ['name', 'username', 'iban']
rows = []
members = Member.active_members.filter(
members = models.Member.active_members.filter(
for member in members:
if (member.current_membership.type != 'honorary'):
if member.current_membership.type != 'honorary':
'name': member.get_full_name(),
'username': member.username,
......@@ -193,7 +201,7 @@ def statistics(request):
member_types = ("member", "supporter", "honorary")
# The numbers
total = Member.active_members.count()
total = models.Member.active_members.count()
context = {
"total_members": total,
......@@ -38,14 +38,13 @@ from django.contrib.auth.views import login
from django.contrib.sitemaps.views import sitemap
from django.views.generic import TemplateView
from django.views.i18n import JavaScriptCatalog
from rest_framework.authtoken import views as rfviews
import members
import registrations
from activemembers.sitemaps import sitemap as activemembers_sitemap
from documents.sitemaps import sitemap as documents_sitemap
from events.sitemaps import sitemap as events_sitemap
from members.sitemaps import sitemap as members_sitemap
from members.views import ObtainAuthToken, ObtainThaliaAuthToken
from partners.sitemaps import sitemap as partners_sitemap
from thabloid.sitemaps import sitemap as thabloid_sitemap
from thaliawebsite.forms import AuthenticationForm
......@@ -99,7 +98,7 @@ urlpatterns = [
url(r'^api/', include([
url(r'wikilogin', views.wiki_login),
url(r'^v1/', include([
url(r'^token-auth', rfviews.obtain_auth_token),
url(r'^token-auth', ObtainThaliaAuthToken.as_view()),
url(r'^', include('events.api.urls')),
url(r'^', include('members.api.urls')),
url(r'^', include('partners.api.urls')),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment