Include example project

This commit is contained in:
Sebastien Corbin
2020-04-18 20:20:26 +02:00
parent ac8c20abb3
commit a6946d160d
10 changed files with 148 additions and 3 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@
htmlcov
*.egg-info
.tox
example.db

View File

@@ -35,8 +35,8 @@ USAGE
# settings.py
INSTALLED_APPS = (
...
'jsignature',
...
'jsignature',
)
* Use provided form field and widget:
@@ -121,7 +121,7 @@ Available settings are:
IN YOUR MODELS
==================
If you wan to store signatures, provided mixin gives a ``signature`` and a ``signature_date`` that update themselves:
If you want to store signatures, provided mixin gives a ``signature`` and a ``signature_date`` that update themselves:
::
@@ -132,11 +132,34 @@ If you wan to store signatures, provided mixin gives a ``signature`` and a ``sig
name = models.CharField()
==================
Example project
==================
If you want to have a demo of this package, just use the example project:
::
git clone https://github.com/fle/django-jsignature.git
cd django-jsignature
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -e .
cd example_project
./manage.py migrate
./manage.py createsuperuser
Fill the user info, launch django with ``./manage.py runserver`` and head over to
`http://127.0.0.1:8000/ <http://127.0.0.1:8000/>`_ and login with the
credentials your provided.
==================
AUTHORS
==================
* Florent Lebreton <florent.lebreton@makina-corpus.com>
* Sébastien Corbin <sebastien.corbin@makina-corpus.com>
|makinacom|_

View File

5
example_project/admin.py Normal file
View File

@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import ExampleModel
admin.site.register(ExampleModel)

10
example_project/manage.py Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

View File

@@ -0,0 +1,26 @@
# Generated by Django 3.0.5 on 2020-04-18 12:18
from django.db import migrations, models
import jsignature.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='ExampleModel',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('signature', jsignature.fields.JSignatureField(blank=True, null=True, verbose_name='Signature')),
('signature_date', models.DateTimeField(blank=True, null=True, verbose_name='Signature date')),
],
options={
'abstract': False,
},
),
]

View File

View File

@@ -0,0 +1,5 @@
from jsignature.mixins import JSignatureFieldsMixin
class ExampleModel(JSignatureFieldsMixin):
pass

View File

@@ -0,0 +1,67 @@
import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
DEBUG = True
ALLOWED_HOSTS = ['*']
MANAGERS = ADMINS = ()
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'example.db'),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
SECRET_KEY = 'notsosecret'
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'OPTIONS': {
'context_processors': (
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.media",
"django.template.context_processors.static",
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages",
),
},
},
]
ROOT_URLCONF = 'example_project.urls'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
'django.contrib.messages',
'jsignature',
'example_project',
)
STATIC_URL = '/static/'
JSIGNATURE_JQUERY = 'admin'

8
example_project/urls.py Normal file
View File

@@ -0,0 +1,8 @@
from __future__ import unicode_literals
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('', admin.site.urls),
]