mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-17 23:39:23 +00:00
April fool day
Définitivement une des blagues de tous les temps
This commit is contained in:
0
april/__init__.py
Normal file
0
april/__init__.py
Normal file
6
april/apps.py
Normal file
6
april/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AprilConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "april"
|
34
april/middleware.py
Normal file
34
april/middleware.py
Normal file
@ -0,0 +1,34 @@
|
||||
import os
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest
|
||||
|
||||
from april import views
|
||||
|
||||
|
||||
class AprilFoolMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request: HttpRequest):
|
||||
if request.user.is_authenticated and request.user.id == os.environ.get(
|
||||
"SLI_ID"
|
||||
):
|
||||
# Sli deserves a special one :)
|
||||
return views.april_fool_sli(request)
|
||||
if self._prank_user(request):
|
||||
return views.april_fool(request)
|
||||
return self.get_response(request)
|
||||
|
||||
@classmethod
|
||||
def _prank_user(cls, request):
|
||||
if request.user.is_anonymous or not request.user.was_subscribed:
|
||||
return False
|
||||
# fool users only if the request isn't originated from the sith itself
|
||||
referer = request.META.get("HTTP_REFERER", None)
|
||||
if referer is not None or urlparse(referer).netloc == settings.SITH_URL:
|
||||
return False
|
||||
# don't fool a user too often, or his UX will become miserable
|
||||
already_pranked = request.COOKIES.get("prankDone")
|
||||
return not already_pranked
|
0
april/migrations/__init__.py
Normal file
0
april/migrations/__init__.py
Normal file
165
april/static/april/age_confirm.scss
Normal file
165
april/static/april/age_confirm.scss
Normal file
@ -0,0 +1,165 @@
|
||||
a, body, div, h3, img, li, p, small, span, ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 14px;
|
||||
color: var(--main-text);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: var(--main-theme);
|
||||
cursor: pointer;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 10px;
|
||||
line-height: 21px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-weight: 700;
|
||||
margin-bottom: 10px;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: inline-block;
|
||||
padding: 7px;
|
||||
border: 0;
|
||||
border-radius: 3px;
|
||||
color: var(--main-text);
|
||||
font-size: 1em;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
button.button {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.button.button-pink {
|
||||
background-color: var(--main-theme);
|
||||
}
|
||||
|
||||
.button.button-close {
|
||||
background-color: var(--gray);
|
||||
color: var(--light-gray);
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
z-index: 20240;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
background-color: var(--main-background);
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal {
|
||||
max-width: 850px;
|
||||
width: 100%;
|
||||
max-height: 100%;
|
||||
overflow: auto;
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 30%;
|
||||
-webkit-transform: translate(-50%, -30%);
|
||||
transform: translate(-50%, -30%);
|
||||
background: var(--darkest-gray);
|
||||
border: 1px solid var(--gray);
|
||||
padding: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .logo-wrapper {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .content {
|
||||
font-size: 1.2em;
|
||||
margin: 30px 0;
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .buttons-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .buttons-wrapper .button-close, #ageDisclaimerWrapper .age-disclaimer-modal .buttons-wrapper .button-pink {
|
||||
font-size: 1.3em;
|
||||
padding: 15px 10px;
|
||||
-webkit-transition: all .2s;
|
||||
transition: all .2s;
|
||||
flex-basis: 40%;
|
||||
max-width: 350px;
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .buttons-wrapper .button-pink:hover {
|
||||
background-color: var(--main-theme-hover);
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .buttons-wrapper .button-close {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .buttons-wrapper .button-close:hover {
|
||||
background-color: var(--mid-gray);
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .parental-control-message {
|
||||
margin-top: 30px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .parental-control-message .block-copyright {
|
||||
position: relative;
|
||||
bottom: 10px;
|
||||
color: var(--shadow-dark-gray);
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .parental-control-message a {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .parental-control-message a:hover {
|
||||
color: var(--main-theme-hover);
|
||||
}
|
||||
|
||||
#ageDisclaimerWrapper .age-disclaimer-modal .age_verification_title {
|
||||
font-size: 2em;
|
||||
font-weight: 700;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
98
april/templates/april/age_confirm.jinja
Normal file
98
april/templates/april/age_confirm.jinja
Normal file
@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="" class="grid">
|
||||
<head>
|
||||
<title>AE UTBM</title>
|
||||
<link rel="shortcut icon" href="{{ static('core/img/favicon.ico') }}">
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--main-text: #ffffff;
|
||||
--lightest-gray: #fafafa;
|
||||
--light-gray: #bbbbbb;
|
||||
--mid-light-gray: #616161;
|
||||
--gray: #4b4b4b;
|
||||
--mid-gray: #363636;
|
||||
--light-mid-gray: #444444;
|
||||
--mid-gray-border: #313131;
|
||||
--dark-gray: #232323;
|
||||
--shadow-dark-gray: #707070;
|
||||
--darkest-gray: #161617;
|
||||
--main-background: #000;
|
||||
--main-theme: #ec567c;
|
||||
--main-theme-hover: #e33561;
|
||||
--error: #b02020;
|
||||
--main-error: #d32f2f;
|
||||
--main-enable: #8faf20;
|
||||
--main-theme-information: #ed6398;
|
||||
--intersti-blue: #00aef1;
|
||||
--tooltip-background: #444444;
|
||||
--tooltip-text: #EEEEEE;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link rel="stylesheet" href="{{ static("april/age_confirm.scss") }}"/>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
|
||||
<script type="module" src="{{ static('bundled/alpine-index.js') }}"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="ageDisclaimerMainBG"
|
||||
style="position:fixed; padding:0; margin:0; top:0; left:0; width: 100%; height: 100%; z-index: 10000; background: #000;"></div>
|
||||
|
||||
<div id="ageDisclaimerWrapper" x-data>
|
||||
<div class="age-disclaimer-modal main">
|
||||
<div class="logo-wrapper">
|
||||
<img src="{{ static('core/img/logo_no_text.png') }}" width="160"/>
|
||||
</div>
|
||||
<p class="age_verification_title">
|
||||
{% trans %}Age Verification{% endtrans %}
|
||||
</p>
|
||||
<div class="content">
|
||||
<p>
|
||||
{% trans trimmed %}
|
||||
This website contains age-restricted materials including blousards
|
||||
and explicit depictions of student activity.
|
||||
By entering, you affirm that you are at least 18 years of age
|
||||
or the age of majority in the campus you are accessing the website from
|
||||
and you consent to viewing explicit student content.
|
||||
{% endtrans %}
|
||||
</p>
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<button
|
||||
id="accessButton"
|
||||
class="button button-pink gtm-event-avmodal"
|
||||
@click="ageConfirm"
|
||||
>
|
||||
{% trans %}I am 18 or older{% endtrans %}
|
||||
</button>
|
||||
<button
|
||||
id="exitButton"
|
||||
class="button button-close gtm-event-avmodal"
|
||||
@click="document.location = 'https://youtu.be/dQw4w9WgXcQ'"
|
||||
>
|
||||
{% trans %}I am under 18{% endtrans %}
|
||||
</button>
|
||||
</div>
|
||||
<div class="parental-control-message">
|
||||
<p>
|
||||
{% trans trimmed %}
|
||||
Our <a href="https://ae.utbm.fr/forum/topic/18125/" target="_blank" rel="noopener nofollow">
|
||||
parental controls page</a> explains if you can access this website
|
||||
{% endtrans %}
|
||||
</p>
|
||||
<span class='block-copyright'>AE UTBM 2025</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
function ageConfirm() {
|
||||
{# If this cookie exists, the middleware shouldn't render this view #}
|
||||
document.cookie = "prankDone=true;Max-Age=3600;"; {# one hour #}
|
||||
document.location.reload();
|
||||
}
|
||||
</script>
|
||||
</html>
|
4
april/templates/april/sli.jinja
Normal file
4
april/templates/april/sli.jinja
Normal file
@ -0,0 +1,4 @@
|
||||
<h1>Service unavailable</h1>
|
||||
<hr>
|
||||
<p>HTTP Error 503 : the service is unavailable</p>
|
||||
<em style="display: none">Review mes PRs, wesh</em>
|
9
april/views.py
Normal file
9
april/views.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
def april_fool(request):
|
||||
return render(request, "april/age_confirm.jinja")
|
||||
|
||||
|
||||
def april_fool_sli(request):
|
||||
return render(request, "april/sli.jinja")
|
Reference in New Issue
Block a user