def post(self, request, *args, **kwargs): if Account.objects.count() == 0: form = InstallForm(request.POST) if form.is_valid(): new_admin = Account( username=request.POST['admin_username'], email=request.POST['admin_email'], is_superuser=True, is_staff=True, is_active=True, banned=False, ) new_admin.set_password(request.POST['admin_password']) new_admin.save() try: initialize_keys() set_key("ctf_name", request.POST['ctf_name']) set_key("installed", True) cache.set("theme", "core") except Exception as exception: logger.error('Installation failed: {0}'.format(exception)) new_admin.backend = 'django.contrib.auth.backends.ModelBackend' login(request, new_admin) return render(request, 'templates/installer/success.html') else: return HttpResponse(status=403)
def setUp(self): self.admin_account = Account.objects.create_superuser( username="******", email="*****@*****.**", password="******", is_superuser=True) self.admin_account.set_password("administrator123") self.admin_account.save() self.test_title = "Example CTF" initialize_keys() set_key("installed", True)
def set_theme(theme): set_key("theme", theme) cache.set("theme", theme)
def post(self, request, *args, **kwargs): form = self.form_class(data=request.POST) if form.is_valid(): if 'theme' in request.POST: set_theme(request.POST['theme']) cache.set("theme", request.POST['theme']) if 'start_time' in request.POST: if request.POST['start_time']: set_key("start_time", request.POST['start_time']) else: set_key("start_time", None) if 'end_time' in request.POST: if request.POST['end_time']: set_key("end_time", request.POST['end_time']) else: set_key("end_time", None) if 'title' in request.POST: set_key("ctf_name", request.POST['title']) if 'scoreboard_users' in request.POST: set_key("scoreboard_users", request.POST['scoreboard_users']) if 'registration_status' in request.POST: set_key("registration_status", request.POST['registration_status']) return HttpResponse(status=204) else: return HttpResponse(status=400)