From 1489b5aa7dd26f55b6fed9717d05e09b20472a35 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sat, 6 Jun 2020 11:37:04 -0500 Subject: [PATCH] Fix captcha and generify community invite Signed-off-by: Etzelia --- external/views.py | 15 ++++++++------- templates/minecraft_manager/external/apply.html | 2 +- templates/minecraft_manager/external/base.html | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/external/views.py b/external/views.py index ce3f693..7f9385e 100644 --- a/external/views.py +++ b/external/views.py @@ -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') diff --git a/templates/minecraft_manager/external/apply.html b/templates/minecraft_manager/external/apply.html index 072c6b2..d376524 100644 --- a/templates/minecraft_manager/external/apply.html +++ b/templates/minecraft_manager/external/apply.html @@ -17,7 +17,7 @@
We will get back to you soon.
- Consider joining our Discord + Consider joining our {{ map.invite_label }} {% endblock %} {% endif %} diff --git a/templates/minecraft_manager/external/base.html b/templates/minecraft_manager/external/base.html index 3819580..74197ad 100644 --- a/templates/minecraft_manager/external/base.html +++ b/templates/minecraft_manager/external/base.html @@ -21,7 +21,7 @@ {% else %}
{% block form %}{{ form }}{% endblock %}

- {% if captcha %}
{% endif %} + {% if captcha %}
{% endif %}
{% endif %}