Browse Source

implemented the logic for having a landingpage with a button poining to oauth login for extern view, while leaving /admin with passwort login

master
alpcentaur 9 months ago
parent
commit
a5834ee8c9
5 changed files with 56 additions and 3 deletions
  1. +1
    -1
      foerderbarometer/settings.py
  2. +3
    -0
      input/middleware/oauth.py
  3. +47
    -0
      input/templates/input/index.html
  4. +3
    -2
      input/urls.py
  5. +2
    -0
      input/views.py

+ 1
- 1
foerderbarometer/settings.py View File

@ -163,7 +163,7 @@ DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# OAuth Settings
OAUTH_URL_WHITELISTS = ['/admin']
OAUTH_URL_WHITELISTS = ['/admin', '/index']
OAUTH_CLIENT_NAME = '<name-of-the-configured-wikimedia-app>'
OAUTH_CLIENT_NAME = get_secret('OAUTH_CLIENT_NAME')

+ 3
- 0
input/middleware/oauth.py View File

@ -14,6 +14,9 @@ class OAuthMiddleware(MiddlewareMixin):
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):

+ 47
- 0
input/templates/input/index.html View File

@ -0,0 +1,47 @@
{% load static %}
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="{% static 'admin/js/core.js' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/vendor/jquery/jquery.js' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/jquery.init.js' %}"></script>
{{ form.media }}
<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;
}
</style>
<p>
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c4/Figuren_klein.jpg"><p>
Eine Übersicht aller Förderangebote von Wikimedia Deutschland findest du im <a href="https://de.wikipedia.org/wiki/Wikipedia:Förderung/Förderangebote">
Förderportal in der deutschsprachigen Wikipedia</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>.
<p>
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>
<a href="http://localhost:8000/extern">OAUTH</a>
</center>

+ 3
- 2
input/urls.py View File

@ -1,9 +1,10 @@
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'),

+ 2
- 0
input/views.py View File

@ -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'''

Loading…
Cancel
Save