1
0
Fork 0

Fixes for gdb with OATH

This commit is contained in:
Tobias Herre 2024-01-08 13:31:18 +00:00
parent fba77f0fe7
commit 4e3d915e90
3 changed files with 13 additions and 55 deletions

View File

@ -17,7 +17,7 @@ from pathlib import Path
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
# prefix for urls in mails # prefix for urls in mails
URLPREFIX = 'http://localhost:8000' URLPREFIX = 'https://fdb-devel.wikimedia.de'
# mails in development go to stdout # mails in development go to stdout
@ -163,7 +163,7 @@ DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# OAuth Settings # OAuth Settings
OAUTH_URL_WHITELISTS = ['/admin', '/index'] OAUTH_URL_WHITELISTS = ['/admin']
OAUTH_CLIENT_NAME = '<name-of-the-configured-wikimedia-app>' OAUTH_CLIENT_NAME = '<name-of-the-configured-wikimedia-app>'
OAUTH_CLIENT_NAME = get_secret('OAUTH_CLIENT_NAME') OAUTH_CLIENT_NAME = get_secret('OAUTH_CLIENT_NAME')
@ -175,7 +175,7 @@ OAUTH_CLIENT = {
'access_token_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/access_token', 'access_token_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/access_token',
'authorize_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/authorize', 'authorize_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/authorize',
'api_base_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/resource', 'api_base_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/resource',
'redirect_uri': 'http://localhost:8000/oauth/callback', 'redirect_uri': 'https://fdb-devel.wikimedia.de/oauth/callback',
'client_kwargs': { 'client_kwargs': {
'scope': 'basic', 'scope': 'basic',
'token_placement': 'header' 'token_placement': 'header'

View File

@ -1,9 +1,7 @@
from datetime import date from datetime import date
from django.utils.http import urlencode
from django.db import models from django.db import models
from django.utils.html import format_html from django.utils.html import format_html
import urllib
from django.utils.safestring import mark_safe
from .settings import ACCOUNTS from .settings import ACCOUNTS
@ -15,7 +13,7 @@ EMAIL_STATES = {'NONE': 'noch keine Mail versendet',
class Volunteer(models.Model): class Volunteer(models.Model):
realname = models.CharField(max_length=200, null=True, verbose_name="Realname", realname = models.CharField(max_length=200, null=True, verbose_name="Realname",
help_text="Bitte gib deinen Vornamen und deinen Nachnamen ein.", default='oi') help_text="Bitte gib deinen Vornamen und deinen Nachnamen ein.", default='')
email = models.EmailField(max_length=200, null=True, verbose_name='E-Mail-Adresse', email = models.EmailField(max_length=200, null=True, verbose_name='E-Mail-Adresse',
help_text=format_html('Bitte gib deine E-Mail-Adresse ein, damit dich<br>Wikimedia Deutschland bei Rückfragen oder für<br>die Zusage kontaktieren kann.')) help_text=format_html('Bitte gib deine E-Mail-Adresse ein, damit dich<br>Wikimedia Deutschland bei Rückfragen oder für<br>die Zusage kontaktieren kann.'))
@ -102,41 +100,13 @@ class Project(Volunteer):
project_of_year = models.IntegerField(default=0) project_of_year = models.IntegerField(default=0)
end_quartal = models.CharField(max_length=15, null=True, blank=True, verbose_name="Quartal Projekt Ende") end_quartal = models.CharField(max_length=15, null=True, blank=True, verbose_name="Quartal Projekt Ende")
def save(self,*args,**kwargs): def save(self,*args,**kwargs):
'''we generate the autogenerated fields here''' '''we generate the autogenerated fields here'''
# we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors # we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors
# but maybe there is a better solution? # but maybe there is a better solution?
preotrs = self.otrs
#postotrs = ''
#for n in range(len(preotrs)):
# if preotrs[n] == ';':
# postotrs += '\;'
# else:
# postotrs += preotrs[n]
#print(self.otrs)
#print(preotrs)
#print(postotrs)
postotrs = urllib.parse.quote(preotrs, safe=':;/=?&')
self.otrs = mark_safe(urllib.parse.unquote(postotrs))
startyear_tmp = 'NONE'
if self.pid:
print('self pid last four', self.pid[:4], self.start.year)
if int(self.pid[:4]) != int(self.start.year):
startyear_tmp = self.start.year
print('the startyear_tmp is as follows ', startyear_tmp)
super().save() super().save()
self.pid = str(self.start.year) + '-' + str(self.account.code) + str(self.pk).zfill(3)
if startyear_tmp == 'NONE': # self.pid = str(self.account.code) + str(self.pk).zfill(3)
self.pid = str(self.start.year) + '-' + str(self.account.code) + str(self.pk).zfill(3)
# self.pid = str(self.account.code) + str(self.pk).zfill(3)
# generation of field quartals # generation of field quartals
if self.end.month in [1, 2, 3]: if self.end.month in [1, 2, 3]:
@ -149,25 +119,13 @@ class Project(Volunteer):
self.end_quartal = 'Q4' self.end_quartal = 'Q4'
# generation of pid and financeID # generation of pid and financeID
# project of year is true if entry gets updated with changes.. but year can change!!!!!!!!
if self.project_of_year:
print('oi oi oi oi oi')
print(self.pid)
# project of year is false if entry gets saved as new
if not self.project_of_year or startyear_tmp != 'NONE':
print('AAA')
print('self projekt of year', self.project_of_year, self.start.year)
if not self.project_of_year:
#print('AAA')
# we need to determine if this is a new year with its first new project... # we need to determine if this is a new year with its first new project...
year = self.start.year year = self.start.year
#print(year) #print(year)
projects = Project.objects.filter(start__year=year) projects = Project.objects.filter(start__year=year)
print('projects after filter of startyear of project',projects)
if not projects: if not projects:
#print('BBB') #print('BBB')
self.project_of_year = 1 self.project_of_year = 1

View File

@ -45,8 +45,8 @@
Herzlich willkommen im Förderanfrageportal von Wikimedia Deutschland! Herzlich willkommen im Förderanfrageportal von Wikimedia Deutschland!
</p> </p>
<div class="div5"></div> <div class="div5"></div>
<a href="http://localhost:8000/extern"style="float:right;padding-right:10%;">OAUTH</a> <!-- <a href="http://fdb-devel.wikimedia.de/extern"style="float:right;padding-right:10%;">OAUTH</a>
<a href="http://localhost:8000/extern" style="float:left;padding-left:10%;">OAUTH</a> <a href="http://fdb-devel.wikimedia.de/extern" style="float:left;padding-left:10%;">OAUTH</a> -->
<p> <p>
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c4/Figuren_klein.jpg"><p> <img src="https://upload.wikimedia.org/wikipedia/commons/c/c4/Figuren_klein.jpg"><p>
Um eine Unterstützungsleistung im Rahmen der Förderangebote anfragen zu können, verifiziere dich bitte mit deinem Wikimedia-Konto. Um eine Unterstützungsleistung im Rahmen der Förderangebote anfragen zu können, verifiziere dich bitte mit deinem Wikimedia-Konto.
@ -55,7 +55,7 @@ Um eine Unterstützungsleistung im Rahmen der Förderangebote anfragen zu könne
Förderportal</a> in der deutschsprachigen Wikipedia. Förderportal</a> in der deutschsprachigen Wikipedia.
<p> <p>
<div class="div5"></div> <div class="div5"></div>
<div class="button button1"><div class="button1_text">Anmelden</div></div> <div class="button button1"><a href="/extern"><div class="button1_text">Anmelden</div></a></div>
<div class="div5"></div> <div class="div5"></div>
<div class="div5"></div> <div class="div5"></div>
<br>Für alle Fragen wende dich gern an das <a href="https://de.wikipedia.org/wiki/Wikipedia:Förderung/Wikimedia_Deutschland">Team Communitys und Engagement</a>. <br>Für alle Fragen wende dich gern an das <a href="https://de.wikipedia.org/wiki/Wikipedia:Förderung/Wikimedia_Deutschland">Team Communitys und Engagement</a>.