You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
from django.shortcuts import render
|
|
from django.contrib.auth.decorators import login_required
|
|
from django.http import HttpResponseRedirect
|
|
from django.urls import reverse
|
|
|
|
from .forms import MntForm, ContactForm
|
|
|
|
|
|
@login_required
|
|
def dbDashboard(request):
|
|
mnts = request.user.maintainer_set.all()
|
|
mntForm = contactForm = None
|
|
|
|
if mnts.count() == 0:
|
|
mntForm = contactForm = None
|
|
if request.method == "POST":
|
|
mntForm = MntForm(data=request.POST, prefix="mnt")
|
|
contactForm = ContactForm(person=True, data=request.POST, prefix="contact")
|
|
if mntForm.is_valid() and contactForm.is_valid():
|
|
mnt = mntForm.save(commit=False)
|
|
mnt.handleAuto(request.user.username)
|
|
mnt.save()
|
|
|
|
contact = contactForm.save(commit=False)
|
|
contact.handleAuto()
|
|
contact.save()
|
|
contact.mnt_by.add(mnt.id)
|
|
contact.save()
|
|
|
|
mnt.auth.add(request.user.id)
|
|
mnt.admin_c.add(contact.id)
|
|
mnt.save()
|
|
|
|
return HttpResponseRedirect(reverse("whoisdb:dashboard"))
|
|
else:
|
|
mntForm = MntForm(prefix="mnt", initial={'handle': 'AUTO', 'description': 'Primary maintainer of %s' % request.user.username})
|
|
contactForm = ContactForm(person=True, initial={'handle': 'AUTO', 'name': request.user.username.capitalize()}, prefix='contact')
|
|
|
|
return render(request, "whoisdb/overview.html", {"mnts": mnts, "mntForm": mntForm, "contactForm": contactForm})
|
|
|
|
|
|
def manageMnt(request, mnt=None):
|
|
if mnt:
|
|
# object or 404
|
|
pass
|
|
return render(request, "whoisdb/overview.html", {})
|