-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add full example of front-office usage
- Loading branch information
Showing
6 changed files
with
168 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<!-- Required meta tags --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
|
||
<!-- Bootstrap CSS --> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | ||
|
||
<title>Example project</title> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-lg navbar-light bg-light"> | ||
<div class="container"> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'admin:index' %}">Admnistration</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'list' %}">List</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'create' %}">Create</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</nav> | ||
|
||
<div class="container"> | ||
{% block content %}{% endblock %} | ||
</div> | ||
|
||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> | ||
{% block extra_media %}{% endblock %} | ||
</body> | ||
</html> |
14 changes: 14 additions & 0 deletions
14
example_project/templates/example_project/examplemodel_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block extra_media %} | ||
{{ form.media }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<form action="" method="post"> | ||
{{ form }} | ||
<input type="submit" value="Save" class="btn btn-success" /> | ||
<a href="{% url 'list' %}" class="btn btn-danger">Cancel</a> | ||
{% csrf_token %} | ||
</form> | ||
{% endblock %} |
24 changes: 24 additions & 0 deletions
24
example_project/templates/example_project/examplemodel_list.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% extends "base.html" %}{% load jsignature_filters %} | ||
|
||
{% block content %} | ||
<h1>List</h1> | ||
|
||
<ul> | ||
{% for obj in object_list %} | ||
<li> | ||
<dl> | ||
<dt>Raw data (from db)</dt> | ||
<dd>{{ obj.signature }}</dd> | ||
<dt>As image</dt> | ||
<dd> | ||
<img src="{{ obj.signature|signature_base64 }}" alt="{{ obj }}" /> | ||
<a href="{% url 'update' obj.pk %}" class="btn btn-primary"> | ||
Update | ||
</a> | ||
</dd> | ||
</dl> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
<a href="{% url 'create' %}" class="btn btn-primary">Create</a> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.urls import reverse_lazy | ||
from django.views import generic | ||
|
||
from example_project.models import ExampleModel | ||
|
||
|
||
class ExampleCreateView(generic.CreateView): | ||
model = ExampleModel | ||
fields = '__all__' | ||
success_url = reverse_lazy('list') | ||
|
||
|
||
class ExampleUpdateView(generic.UpdateView): | ||
model = ExampleModel | ||
fields = '__all__' | ||
success_url = reverse_lazy('list') | ||
|
||
|
||
class ExampleListView(generic.ListView): | ||
model = ExampleModel |