forked from beba/foerderbarometer
Compare commits
72 Commits
master
...
oauth_with
Author | SHA1 | Date |
---|---|---|
Tobias Herre | 4e3d915e90 | |
Tobias Herre | fba77f0fe7 | |
Tobias Herre | 442cd73b03 | |
alpcentaur | 6b41d3320b | |
alpcentaur | a5834ee8c9 | |
alpcentaur | a51552d4dd | |
alpcentaur | 1454fce9ba | |
alpcentaur | 7c05040d7b | |
Tobias Herre | 3f4d218c08 | |
alpcentaur | c113e37b3f | |
alpcentaur | f60623d485 | |
alpcentaur | d0fb14bf17 | |
alpcentaur | 4b7423cd76 | |
alpcentaur | 777d05c26c | |
alpcentaur | 5adea3755a | |
alpcentaur | 9537aaf667 | |
alpcentaur | fc0414a286 | |
alpcentaur | 440df28b0e | |
alpcentaur | 5c35948859 | |
alpcentaur | ebdc3be903 | |
alpcentaur | cf784a05f1 | |
alpcentaur | e32cc87f63 | |
alpcentaur | c29b410ec5 | |
alpcentaur | 0b7b161383 | |
alpcentaur | b8cdaa1bf7 | |
alpcentaur | 9200459028 | |
alpcentaur | 29cdd7b653 | |
alpcentaur | 914989d6ac | |
alpcentaur | 6d3888172f | |
alpcentaur | 08dd961cbe | |
alpcentaur | 5402733a9c | |
alpcentaur | 5b91d335de | |
alpcentaur | 94f82d5733 | |
alpcentaur | 1d9811b0ff | |
alpcentaur | 0b450feac9 | |
alpcentaur | a064b78958 | |
alpcentaur | e638afabd5 | |
alpcentaur | 402a6f047c | |
alpcentaur | b451cbbb16 | |
alpcentaur | 37e629de70 | |
alpcentaur | 73ad8f90cf | |
alpcentaur | 26a1c9a500 | |
alpcentaur | 76d68531f9 | |
alpcentaur | 997c45d1ee | |
alpcentaur | bdd6d25b70 | |
alpcentaur | a117b484d9 | |
alpcentaur | d9db5238ea | |
alpcentaur | 1050308712 | |
alpcentaur | e9de3fcb99 | |
alpcentaur | 2254b77a0d | |
alpcentaur | 34857ccf03 | |
alpcentaur | 1ed10b2b8c | |
alpcentaur | 5eb2ee2b9d | |
alpcentaur | 980ee45066 | |
alpcentaur | f58ac52109 | |
alpcentaur | a8d8f6fdd6 | |
alpcentaur | 0d72a4b7c0 | |
alpcentaur | 960ec8841c | |
alpcentaur | 95774952e2 | |
alpcentaur | 9bc852a23e | |
alpcentaur | 95e9bdd5a8 | |
alpcentaur | b5b0dc61e4 | |
alpcentaur | cb6710e758 | |
alpcentaur | 2f4ee1ee13 | |
alpcentaur | 9d0f8fd477 | |
alpcentaur | 418fef477a | |
alpcentaur | 28e1570bee | |
alpcentaur | f6ae9e640e | |
alpcentaur | 94d8d7a50b | |
alpcentaur | 14de26de70 | |
alpcentaur | b403ef1cdd | |
alpcentaur | 4ba8ad0e6c |
|
@ -2,8 +2,8 @@
|
|||
/secrets.json
|
||||
/staticfiles
|
||||
# /foerderbarometer/settings.py
|
||||
/foerderbarometer/*settings*
|
||||
/foerderbarometer/input/settings.py
|
||||
# /foerderbarometer/*settings*
|
||||
/input/settings.py
|
||||
/nohup.out
|
||||
/logfile
|
||||
*~
|
||||
|
|
26
README.md
26
README.md
|
@ -35,11 +35,27 @@ entries to a csv file
|
|||
|
||||
## versions used in development
|
||||
|
||||
python 3.8.2
|
||||
django 3.1.x (does not work with django 3.2 in the moment!)
|
||||
django-formtools 2.2
|
||||
whitenoise 5.2.0
|
||||
gunicorn 20.0.4
|
||||
asgiref==3.2.10
|
||||
Django==3.1.2
|
||||
django-formtools==2.4
|
||||
gunicorn==20.0.4
|
||||
mysqlclient==2.1.1
|
||||
sqlparse==0.4.3
|
||||
whitenoise==6.2.0
|
||||
asgiref==3.2.10
|
||||
Authlib==1.2.1
|
||||
certifi==2023.7.22
|
||||
cffi==1.16.0
|
||||
chardet==5.2.0
|
||||
charset-normalizer==3.3.0
|
||||
cryptography==41.0.4
|
||||
idna==3.4
|
||||
pycparser==2.21
|
||||
pytz==2023.3.post1
|
||||
requests==2.31.0
|
||||
six==1.16.0
|
||||
typing_extensions==4.8.0
|
||||
urllib3==2.0.6
|
||||
|
||||
## testing
|
||||
|
||||
|
|
|
@ -0,0 +1,186 @@
|
|||
"""
|
||||
Django settings for foerderbarometer project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 3.1.1.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.1/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/3.1/ref/settings/
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
# prefix for urls in mails
|
||||
URLPREFIX = 'https://fdb-devel.wikimedia.de'
|
||||
|
||||
|
||||
# mails in development go to stdout
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
|
||||
# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||
|
||||
#EMAIL_HOST = 'email.wikimedia.de'
|
||||
#EMAIL_PORT = '587'
|
||||
#EMAIL_USE_TLS = True
|
||||
#EMAIL_HOST_USER = get_secret('EMAIL_HOST_USER')
|
||||
#EMAIL_HOST_PASSWORD = get_secret('EMAIL_HOST_PASSWORD')
|
||||
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
# get secrets
|
||||
with open(os.path.join(BASE_DIR, 'secrets.json')) as secrets_file:
|
||||
secrets = json.load(secrets_file)
|
||||
|
||||
def get_secret(setting, secrets=secrets):
|
||||
"""Get secret setting or fail with ImproperlyConfigured"""
|
||||
try:
|
||||
return secrets[setting]
|
||||
except KeyError:
|
||||
raise ImproperlyConfigured("Set the {} setting".format(setting))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = get_secret('SECRET_KEY')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'input.apps.InputConfig',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'formtools',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'input.middleware.oauth.OAuthMiddleware'
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'foerderbarometer.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'foerderbarometer.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
'PASSWORD': get_secret('DATABASE_PASSWORD')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/3.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# needed since django 3.2
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||
|
||||
|
||||
# OAuth Settings
|
||||
OAUTH_URL_WHITELISTS = ['/admin']
|
||||
|
||||
OAUTH_CLIENT_NAME = '<name-of-the-configured-wikimedia-app>'
|
||||
OAUTH_CLIENT_NAME = get_secret('OAUTH_CLIENT_NAME')
|
||||
|
||||
|
||||
OAUTH_CLIENT = {
|
||||
'client_id': get_secret('OAUTH_CLIENT_ID'),
|
||||
'client_secret': get_secret('OAUTH_CLIENT_SECRET'),
|
||||
'access_token_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/access_token',
|
||||
'authorize_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/authorize',
|
||||
'api_base_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/resource',
|
||||
'redirect_uri': 'https://fdb-devel.wikimedia.de/oauth/callback',
|
||||
'client_kwargs': {
|
||||
'scope': 'basic',
|
||||
'token_placement': 'header'
|
||||
},
|
||||
'userinfo_endpoint': 'resource/profile',
|
||||
}
|
||||
|
||||
OAUTH_COOKIE_SESSION_ID = 'sso_session_id'
|
|
@ -36,6 +36,11 @@ class ProjectAdmin(admin.ModelAdmin):
|
|||
date_hierarchy = 'end'
|
||||
readonly_fields = ('end_quartal', 'project_of_year', 'pid', 'finance_id')
|
||||
|
||||
class Media:
|
||||
js = ('dropdown/js/otrs_link.js',)
|
||||
|
||||
|
||||
|
||||
@admin.register(BusinessCard)
|
||||
class BusinessCardAdmin(admin.ModelAdmin):
|
||||
save_as = True
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
ASGI config for oauth_demo project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'oauth_demo.settings')
|
||||
|
||||
application = get_asgi_application()
|
|
@ -26,6 +26,9 @@ class ProjectForm(FdbForm):
|
|||
widgets = {'start': AdminDateWidget(),
|
||||
'end': AdminDateWidget(),}
|
||||
|
||||
class Media:
|
||||
js = ('dropdown/js/otrs_link.js',)
|
||||
|
||||
|
||||
class ExternForm(FdbForm):
|
||||
|
||||
|
@ -38,7 +41,7 @@ class ExternForm(FdbForm):
|
|||
|
||||
class Meta:
|
||||
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',
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
from authlib.integrations.base_client import OAuthError
|
||||
from authlib.integrations.django_client import OAuth
|
||||
from authlib.oauth2.rfc6749 import OAuth2Token
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from foerderbarometer import settings
|
||||
from input import views
|
||||
from input import models
|
||||
|
||||
class OAuthMiddleware(MiddlewareMixin):
|
||||
|
||||
def __init__(self, get_response=None):
|
||||
super().__init__(get_response)
|
||||
self.oauth = OAuth()
|
||||
|
||||
def process_request(self, request):
|
||||
# added this if clause to get the landing page before oauth
|
||||
if request.path == '/':
|
||||
return self.get_response(request)
|
||||
if settings.OAUTH_URL_WHITELISTS is not None:
|
||||
for w in settings.OAUTH_URL_WHITELISTS:
|
||||
if request.path.startswith(w):
|
||||
return self.get_response(request)
|
||||
|
||||
def update_token(token, refresh_token, access_token):
|
||||
request.session['token'] = token
|
||||
print('oioi')
|
||||
print('oi token', token)
|
||||
return None
|
||||
|
||||
sso_client = self.oauth.register(
|
||||
settings.OAUTH_CLIENT_NAME, overwrite=True, **settings.OAUTH_CLIENT, update_token=update_token
|
||||
)
|
||||
|
||||
if request.path.startswith('/oauth/callback'):
|
||||
print('oi')
|
||||
self.clear_session(request)
|
||||
request.session['token'] = sso_client.authorize_access_token(request)
|
||||
# print('blub', request.session['token'])
|
||||
models.Extern.username = self.get_current_user(sso_client, request)['username']
|
||||
if self.get_current_user(sso_client, request) is not None:
|
||||
redirect_uri = request.session.pop('redirect_uri', None)
|
||||
if redirect_uri is not None:
|
||||
return redirect(redirect_uri)
|
||||
return redirect(views.ExternView)
|
||||
|
||||
if request.session.get('token', None) is not None:
|
||||
current_user = self.get_current_user(sso_client, request)
|
||||
if current_user is not None:
|
||||
return self.get_response(request)
|
||||
|
||||
# remember redirect URI for redirecting to the original URL.
|
||||
request.session['redirect_uri'] = request.path
|
||||
return sso_client.authorize_redirect(request, settings.OAUTH_CLIENT['redirect_uri'])
|
||||
|
||||
# fetch current login user info
|
||||
# 1. check if it's in cache
|
||||
# 2. fetch from remote API when it's not in cache
|
||||
@staticmethod
|
||||
def get_current_user(sso_client, request):
|
||||
token = request.session.get('token', None)
|
||||
if token is None or 'access_token' not in token:
|
||||
return None
|
||||
|
||||
if not OAuth2Token.from_dict(token).is_expired() and 'user' in request.session:
|
||||
return request.session['user']
|
||||
|
||||
try:
|
||||
res = sso_client.get(settings.OAUTH_CLIENT['userinfo_endpoint'], token=OAuth2Token(token))
|
||||
print('json oi oi' , res.json())
|
||||
if res.ok:
|
||||
request.session['user'] = res.json()
|
||||
return res.json()
|
||||
except OAuthError as e:
|
||||
print(e)
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def clear_session(request):
|
||||
try:
|
||||
del request.session['user']
|
||||
del request.session['token']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def __del__(self):
|
||||
print('destroyed')
|
|
@ -13,11 +13,12 @@ EMAIL_STATES = {'NONE': 'noch keine Mail versendet',
|
|||
|
||||
class Volunteer(models.Model):
|
||||
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='')
|
||||
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.'))
|
||||
|
||||
# the following Fields are not supposed to be edited by users
|
||||
|
||||
granted = models.BooleanField(null=True, verbose_name='bewilligt')
|
||||
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)
|
||||
|
@ -36,10 +37,12 @@ class Volunteer(models.Model):
|
|||
abstract = True
|
||||
|
||||
|
||||
|
||||
class Extern(Volunteer):
|
||||
''' abstract basis class for all data entered by extern volunteers '''
|
||||
|
||||
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
|
||||
service_id = models.CharField(max_length=15, null=True, blank=True)
|
||||
|
|
|
@ -39,3 +39,33 @@ ACCOUNTS ={ # "21103": '21103 Willkommen',
|
|||
"21140": '21140 Wikipedia-Kampagne',
|
||||
"21141": '21141 Wikipedia-Onboarding',
|
||||
"21150": '21150 Fürsorge und Online-Kommunikationskultur',}
|
||||
|
||||
|
||||
|
||||
# teken from working oauth prototype as additional settings
|
||||
|
||||
WSGI_APPLICATION = 'oauth_demo.wsgi.application'
|
||||
|
||||
# OAuth Settings
|
||||
OAUTH_URL_WHITELISTS = []
|
||||
|
||||
OAUTH_CLIENT_NAME = '<name-of-the-configured-wikimedia-app>'
|
||||
|
||||
|
||||
|
||||
OAUTH_CLIENT = {
|
||||
'client_id': '<client-application-key-of-wikimedia-app>',
|
||||
'client_secret': '<client-application-secret-of-wikimedia-app>',
|
||||
'access_token_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/access_token',
|
||||
'authorize_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/authorize',
|
||||
'api_base_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/resource',
|
||||
'redirect_uri': 'http://localhost:8000/oauth/callback',
|
||||
'client_kwargs': {
|
||||
'scope': 'basic',
|
||||
'token_placement': 'header'
|
||||
},
|
||||
'userinfo_endpoint': 'resource/profile',
|
||||
}
|
||||
|
||||
OAUTH_COOKIE_SESSION_ID = 'sso_session_id'
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# mail for IF-OTRS
|
||||
IF_EMAIL = 'community@wikimedia.de'
|
||||
#IF_EMAIL = 'test-luca-ext@wikimedia.de'
|
||||
#SURVEY_EMAIL = 'christof.pins@wikimedia.de'
|
||||
#SURVEY_EMAIL = 'luca.wulf@cannabinieri.de'
|
||||
SURVEY_EMAIL = 'sandro.halank@wikimedia.de'
|
||||
# prefix for urls
|
||||
SURVEYPREFIX = 'https://wikimedia.sslsurvey.de/Foerderbarometer/?'
|
||||
|
||||
# some links
|
||||
DATAPROTECTION = "https://www.wikimedia.de/datenschutz/#datenerfassung"
|
||||
FOERDERRICHTLINIEN = "https://de.wikipedia.org/wiki/Wikipedia:Wikimedia_Deutschland/F%C3%B6rderrichtlinien"
|
||||
NUTZUNGSBEDINGUNGEN = 'static/input/nutzungsbedingungen.html'
|
||||
|
||||
LANGUAGE_CODE = 'de'
|
||||
TIME_ZONE = 'UTC'
|
||||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
ACCOUNTS ={ # "21103": '21103 Willkommen',
|
||||
"DEF": 'DEFAULT VALUE, you hould not see this!',
|
||||
"21111": '21111 Förderung (reaktiv)',
|
||||
"21112": '21112 WikiCon',
|
||||
# "21113": '21113 Wikimania/Unterstützung Ehrenamtliche',
|
||||
"21115": '21115 Lokale Räume, Berlin',
|
||||
"21116": '21116 Lokale Räume, Hamburg',
|
||||
"21117": '21117 Lokale Räume, Hannover',
|
||||
"21118": '21118 Lokale Räume, Köln',
|
||||
"21119": '21119 Lokale Räume, München',
|
||||
"21120": '21120 Lokale Räume, Fürth',
|
||||
"21125": '21125 Lokale Räume, allgemein',
|
||||
"21130": '21130 GLAM-Förderung',
|
||||
"21131": '21131 Initiative Förderung',
|
||||
# "21134": '21134 Größe',
|
||||
# "21137": '21137 Beitragen',
|
||||
# "21138": '21138 Vermittlung',
|
||||
"21140": '21140 Wikipedia-Kampagne',
|
||||
"21141": '21141 Wikipedia-Onboarding',
|
||||
"21150": '21150 Fürsorge und Online-Kommunikationskultur',}
|
|
@ -0,0 +1,19 @@
|
|||
window.addEventListener("load", function() {
|
||||
(function($) {
|
||||
$(function() {
|
||||
|
||||
let otrs_link = document.querySelector(".field-otrs > div > p.url > a").href;
|
||||
console.log(otrs_link);
|
||||
alert(otrs_link);
|
||||
|
||||
let otrs_link_pret = otrs_link.replace(/%3B/g, ";");
|
||||
let otrs_link_pretty = otrs_link_pret.replace(/%3D/g, "=");
|
||||
|
||||
console.log(otrs_link_pretty);
|
||||
|
||||
document.querySelector(".field-otrs > div > p.url > a").href = otrs_link_pretty;
|
||||
|
||||
|
||||
});
|
||||
})(django.jQuery);
|
||||
});
|
|
@ -0,0 +1,69 @@
|
|||
{% load static %}
|
||||
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/base.css' %}" />
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/widgets.css' %}" />
|
||||
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% csrf_token %}
|
||||
|
||||
|
||||
<center>
|
||||
<style>
|
||||
ul > li {
|
||||
list-style-type: none;
|
||||
}
|
||||
ul {
|
||||
padding-left: 10;
|
||||
}
|
||||
label.required::after {
|
||||
content: ' *';
|
||||
color: red;
|
||||
}
|
||||
.div15 {
|
||||
height: 15%;
|
||||
}
|
||||
.div5 {
|
||||
height: 5%;
|
||||
}
|
||||
.button1 {
|
||||
width: 40vw;
|
||||
height: 6vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
font-size: 4vh;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="div5"></div>
|
||||
<p>
|
||||
Herzlich willkommen im Förderanfrageportal von Wikimedia Deutschland!
|
||||
</p>
|
||||
<div class="div5"></div>
|
||||
<!-- <a href="http://fdb-devel.wikimedia.de/extern"style="float:right;padding-right:10%;">OAUTH</a>
|
||||
<a href="http://fdb-devel.wikimedia.de/extern" style="float:left;padding-left:10%;">OAUTH</a> -->
|
||||
<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.
|
||||
<br>Weitere Informationen und Hintergründe findest du unter
|
||||
<a href="https://de.wikipedia.org/wiki/Wikipedia:Förderung/Förderangebote">
|
||||
Förderportal</a> in der deutschsprachigen Wikipedia.
|
||||
<p>
|
||||
<div class="div5"></div>
|
||||
<div class="button button1"><a href="/extern"><div class="button1_text">Anmelden</div></a></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 interessierte Hacker gibts auch den <a href="https://srcsrv.wikimedia.de/beba/foerderbarometer">Sourcecode</a> zum Formular und was damit passiert.
|
||||
<p>
|
||||
<a href="https://www.wikimedia.de/impressum/">Impressum</a>
|
||||
<p>
|
||||
</center>
|
||||
|
||||
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
from django.urls import path
|
||||
from .views import ExternView, done, authorize, deny, InternView, export
|
||||
|
||||
from .views import ExternView, index, done, authorize, deny, InternView, export
|
||||
from django.contrib import admin
|
||||
|
||||
urlpatterns = [
|
||||
path('', ExternView.as_view(), name='extern'),
|
||||
path('', index, name='index'),
|
||||
path('extern', ExternView.as_view(), name='extern'),
|
||||
# path('intern', InternView.as_view(), name='intern'),
|
||||
path('admin/', admin.site.urls),
|
||||
path('saved', done, name='done'),
|
||||
path('export', export, name='export'),
|
||||
path('authorize/<str:choice>/<int:pk>', authorize, name='authorize'),
|
||||
|
|
|
@ -70,6 +70,8 @@ def deny(request, choice, pk):
|
|||
def done(request):
|
||||
return HttpResponse("Deine Anfrage wurde gesendet. Du erhältst in Kürze eine E-Mail-Benachrichtigung mit deinen Angaben. Für alle Fragen kontaktiere bitte das Team Communitys und Engagement unter community@wikimedia.de.")
|
||||
|
||||
def index(request):
|
||||
return render(request, 'input/index.html')
|
||||
|
||||
class InternView(LoginRequiredMixin, CookieWizardView):
|
||||
'''This View is for WMDE-employees only'''
|
||||
|
@ -216,6 +218,8 @@ class ExternView(CookieWizardView):
|
|||
data = {}
|
||||
for form in form_list:
|
||||
data = {**data, **form.cleaned_data}
|
||||
|
||||
data['username'] = self.request.session['user']['username']
|
||||
|
||||
if data['choice'] == 'LIT':
|
||||
if data['selfbuy'] == 'TRUE':
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
asgiref==3.2.10
|
||||
Authlib==1.2.1
|
||||
certifi==2023.7.22
|
||||
cffi==1.16.0
|
||||
chardet==5.2.0
|
||||
charset-normalizer==3.3.0
|
||||
cryptography==41.0.4
|
||||
Django==3.1.2
|
||||
django-formtools==2.4
|
||||
gunicorn==20.0.4
|
||||
idna==3.4
|
||||
mysqlclient==2.1.1
|
||||
pycparser==2.21
|
||||
pytz==2023.3.post1
|
||||
requests==2.31.0
|
||||
six==1.16.0
|
||||
sqlparse==0.4.3
|
||||
typing_extensions==4.8.0
|
||||
urllib3==2.0.6
|
||||
whitenoise==6.2.0
|
||||
|
|
Loading…
Reference in New Issue