Fix captcha and generify community invite
Signed-off-by: Etzelia <etzelia@hotmail.com>captcha
parent
faa342933e
commit
1489b5aa7d
|
@ -1,5 +1,5 @@
|
|||
from django.views.generic import View
|
||||
from django.shortcuts import render, reverse, redirect
|
||||
from django.shortcuts import render
|
||||
from django.conf import settings
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
@ -8,12 +8,13 @@ import minecraft_manager.api.api as mcm_api
|
|||
import minecraft_manager.utils as mcm_utils
|
||||
import minecraft_manager.external.stats as mcm_stats
|
||||
from minecraft_manager.models import Player
|
||||
import random, yaml, os, json, datetime, pytz
|
||||
import random, yaml, os
|
||||
|
||||
|
||||
def config():
|
||||
data = {}
|
||||
data['discord_invite'] = getattr(settings, "DISCORD_INVITE", "#")
|
||||
data['invite_link'] = getattr(settings, "INVITE_LINK", "#")
|
||||
data['invite_label'] = getattr(settings, "INVITE_LABEL", "community")
|
||||
|
||||
dynmap_url = getattr(settings, "DYNMAP_URL", "")
|
||||
data['dynmap_url'] = dynmap_url
|
||||
|
@ -60,7 +61,7 @@ class Apply(View):
|
|||
form = ApplicationForm()
|
||||
return render(request, 'minecraft_manager/external/apply.html',
|
||||
{'form': form.as_p(), 'rules': rules(), 'valid': False, 'map': config(),
|
||||
'captcha': hasattr(settings, "CAPTCHA_SECRET")})
|
||||
'captcha': getattr(settings, "CAPTCHA_SITE", "")})
|
||||
|
||||
def post(self, request):
|
||||
form = ApplicationForm(request.POST)
|
||||
|
@ -79,7 +80,7 @@ class Apply(View):
|
|||
form.add_error(None, "That username is not a premium Minecraft account")
|
||||
return render(request, 'minecraft_manager/external/apply.html',
|
||||
{'form': form.as_p(), 'rules': rules(), 'valid': valid and valid_username and captcha.success, 'map': config(),
|
||||
'captcha': hasattr(settings, "CAPTCHA_SECRET")})
|
||||
'captcha': getattr(settings, "CAPTCHA_SITE", "")})
|
||||
|
||||
|
||||
@method_decorator(csrf_exempt, name='dispatch')
|
||||
|
@ -89,7 +90,7 @@ class Ticket(View):
|
|||
form = TicketForm()
|
||||
return render(request, 'minecraft_manager/external/ticket.html',
|
||||
{'form': form.as_p(), 'valid': False, 'map': config(),
|
||||
'captcha': hasattr(settings, "CAPTCHA_SECRET")})
|
||||
'captcha': getattr(settings, "CAPTCHA_SITE", "")})
|
||||
|
||||
def post(self, request):
|
||||
post = request.POST.copy()
|
||||
|
@ -120,7 +121,7 @@ class Ticket(View):
|
|||
form.data['player'] = username
|
||||
return render(request, 'minecraft_manager/external/ticket.html',
|
||||
{'form': form.as_p(), 'valid': valid and captcha.success, 'map': config(),
|
||||
'captcha': hasattr(settings, "CAPTCHA_SECRET")})
|
||||
'captcha': getattr(settings, "CAPTCHA_SITE", "")})
|
||||
|
||||
|
||||
@method_decorator(csrf_exempt, name='dispatch')
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<br/>
|
||||
We will get back to you soon.
|
||||
<br/>
|
||||
Consider joining our <a href="https://discord.gg/{{ map.discord_invite }}">Discord</a></h2>
|
||||
Consider joining our <a href="{{ map.invite_link }}">{{ map.invite_label }}</a></h2>
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
{% else %}
|
||||
<form method="{% block method %}POST{% endblock %}">
|
||||
{% block form %}{{ form }}{% endblock %}<br/><br/>
|
||||
{% if captcha %}<div class="g-recaptcha" data-sitekey="6LeLcGEUAAAAAMMpHR-7VL6Q3nNV5v03S5sq1Ddz"></div>{% endif %}
|
||||
{% if captcha %}<div class="g-recaptcha" data-sitekey="{{ captcha }}"></div>{% endif %}
|
||||
<button type="submit">{% block submit %}Submit{% endblock %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue