51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""Ohlhafv views."""
|
|
|
|
from django.db.models import Count
|
|
from django.shortcuts import render, redirect
|
|
from django.contrib.auth import login, logout, authenticate
|
|
from django.views.decorators.http import require_http_methods
|
|
from django.views.decorators.csrf import ensure_csrf_cookie
|
|
from django.http import HttpResponse, HttpResponseRedirect
|
|
from django.contrib.auth.decorators import permission_required, login_required
|
|
from django.conf import settings
|
|
|
|
import logging
|
|
import requests
|
|
from dealer.git import git
|
|
|
|
from ohlhafv.models import OhlhafvChallenge
|
|
from ohlhafv.forms import OhlhafvForm
|
|
from ohlhafv.tables import OhlhafvTable
|
|
|
|
|
|
@require_http_methods(["GET"])
|
|
def ohlhafv_view(request, *args, **kwargs):
|
|
"""Render Ohlhafv form page."""
|
|
form = OhlhafvForm()
|
|
return render(request, 'ohlhafv:new.html', {'form': form})
|
|
|
|
|
|
@ensure_csrf_cookie
|
|
@require_http_methods(["POST"])
|
|
def ohlhafv_submit(request, *args, **kwargs):
|
|
"""Submit Ohlhafv form."""
|
|
form = OhlhafvForm(request.POST)
|
|
if form.is_valid():
|
|
form.save()
|
|
else:
|
|
pass
|
|
return HttpResponseRedirect('/ohlhafv/list/')
|
|
|
|
|
|
@ensure_csrf_cookie
|
|
@require_http_methods(["GET"])
|
|
def ohlhafv_list(request, *args, **kwargs):
|
|
"""Present Ohlhafv challenges list."""
|
|
challenges = OhlhafvChallenge.objects.all()
|
|
challenges = challenges.order_by('-id')
|
|
context = {
|
|
'challenges': challenges,
|
|
'challenge_count': len(challenges),
|
|
}
|
|
return render(request, 'ohlhafv:list.html', context)
|