Create repo form
This commit is contained in:
parent
373434c3ef
commit
cb2c342449
7
borgweb/borg/forms.py
Normal file
7
borgweb/borg/forms.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
|
||||||
|
class RepoForm(forms.Form):
|
||||||
|
fingerprint = forms.CharField(label='Fingerprint')
|
||||||
|
location = forms.CharField(label='Location')
|
||||||
|
last_modified = forms.DateTimeField(label='Last Modified', input_formats=["%Y-%m-%dT%H:%M:%S.%z"])
|
14
borgweb/borg/templates/borg/repo.html
Normal file
14
borgweb/borg/templates/borg/repo.html
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Add repo</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form action="repo" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form }}
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -4,4 +4,5 @@ from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name='index'),
|
path('', views.index, name='index'),
|
||||||
|
path('repo', views.get_repo, name='repo')
|
||||||
]
|
]
|
|
@ -1,6 +1,9 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
|
|
||||||
from .models import Repo
|
from .models import Repo
|
||||||
|
from .forms import RepoForm
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
|
@ -12,3 +15,22 @@ def index(request):
|
||||||
'hour_list': hour_list
|
'hour_list': hour_list
|
||||||
}
|
}
|
||||||
return render(request, 'borg/index.html', context)
|
return render(request, 'borg/index.html', context)
|
||||||
|
|
||||||
|
|
||||||
|
def get_repo(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
# create a form instance and populate it with data from the request:
|
||||||
|
form = RepoForm(request.POST)
|
||||||
|
# check whether it's valid:
|
||||||
|
if form.is_valid():
|
||||||
|
print(form.cleaned_data)
|
||||||
|
# process the data in form.cleaned_data as required
|
||||||
|
# ...
|
||||||
|
# redirect to a new URL:
|
||||||
|
return HttpResponseRedirect(reverse('index'))
|
||||||
|
|
||||||
|
# if a GET (or any other method) we'll create a blank form
|
||||||
|
else:
|
||||||
|
form = RepoForm()
|
||||||
|
|
||||||
|
return render(request, 'borg/repo.html', {'form': form})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user