1
0
Fork 0

user gets automatically written, not in the form anymore

This commit is contained in:
alpcentaur 2023-10-25 15:50:40 +00:00
parent d0fb14bf17
commit f60623d485
4 changed files with 11 additions and 6 deletions

View File

@ -38,7 +38,7 @@ class ExternForm(FdbForm):
class Meta: class Meta:
model = ConcreteExtern model = ConcreteExtern
exclude = ('granted', 'granted_date', 'survey_mail_send', 'service_id', 'survey_mail_date', 'mail_state') exclude = ('username', 'granted', 'granted_date', 'survey_mail_send', 'service_id', 'survey_mail_date', 'mail_state')
INTERN_CHOICES = {'PRO': 'Projektsteckbrief', INTERN_CHOICES = {'PRO': 'Projektsteckbrief',

View File

@ -5,7 +5,7 @@ from django.shortcuts import redirect
from django.utils.deprecation import MiddlewareMixin from django.utils.deprecation import MiddlewareMixin
from foerderbarometer import settings from foerderbarometer import settings
from input import views from input import views
from input import models
class OAuthMiddleware(MiddlewareMixin): class OAuthMiddleware(MiddlewareMixin):
@ -33,8 +33,8 @@ class OAuthMiddleware(MiddlewareMixin):
print('oi') print('oi')
self.clear_session(request) self.clear_session(request)
request.session['token'] = sso_client.authorize_access_token(request) request.session['token'] = sso_client.authorize_access_token(request)
print('blub', request.session['token']) # print('blub', request.session['token'])
print('user', self.get_current_user(sso_client, request)) models.Extern.username = self.get_current_user(sso_client, request)['username']
if self.get_current_user(sso_client, request) is not None: if self.get_current_user(sso_client, request) is not None:
redirect_uri = request.session.pop('redirect_uri', None) redirect_uri = request.session.pop('redirect_uri', None)
if redirect_uri is not None: if redirect_uri is not None:

View File

@ -13,11 +13,12 @@ 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.") help_text="Bitte gib deinen Vornamen und deinen Nachnamen ein.", default='oi')
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.'))
# the following Fields are not supposed to be edited by users # the following Fields are not supposed to be edited by users
granted = models.BooleanField(null=True, verbose_name='bewilligt') granted = models.BooleanField(null=True, verbose_name='bewilligt')
granted_date = models.DateField(null=True, verbose_name='bewilligt am') granted_date = models.DateField(null=True, verbose_name='bewilligt am')
survey_mail_date = models.DateField(verbose_name='Umfragemail wurde verschickt am', null=True, blank=True) survey_mail_date = models.DateField(verbose_name='Umfragemail wurde verschickt am', null=True, blank=True)
@ -36,10 +37,12 @@ class Volunteer(models.Model):
abstract = True abstract = True
class Extern(Volunteer): class Extern(Volunteer):
''' abstract basis class for all data entered by extern volunteers ''' ''' abstract basis class for all data entered by extern volunteers '''
username = models.CharField(max_length=200, null=True, verbose_name='Benutzer_innenname', username = models.CharField(max_length=200, null=True, verbose_name='Benutzer_innenname',
help_text=format_html("Bitte gib den Namen ein, mit dem du dich<br>in den Wikimedia-Projekten registriert hast.")) help_text=format_html("Wikimedia Benutzer_innenname"))
# the following Fields are not supposed to be edited by users # the following Fields are not supposed to be edited by users
service_id = models.CharField(max_length=15, null=True, blank=True) service_id = models.CharField(max_length=15, null=True, blank=True)

View File

@ -217,6 +217,8 @@ class ExternView(CookieWizardView):
for form in form_list: for form in form_list:
data = {**data, **form.cleaned_data} data = {**data, **form.cleaned_data}
data['username'] = self.request.session['user']['username']
if data['choice'] == 'LIT': if data['choice'] == 'LIT':
if data['selfbuy'] == 'TRUE': if data['selfbuy'] == 'TRUE':
data['selfbuy_give_data'] = 'False' data['selfbuy_give_data'] = 'False'