-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2694d15
Showing
26 changed files
with
984 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
/lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
tests/openwisp2/media/ | ||
tests/openwisp2/firmware/ | ||
!tests/openwisp2/firmware/fake-img*.bin | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# editors | ||
*.komodoproject | ||
.vscode | ||
|
||
# other | ||
*.DS_Store* | ||
*~ | ||
._* | ||
local_settings.py | ||
*.db | ||
*.tar.gz | ||
Pipfile | ||
|
||
# celery | ||
tests/celerybeat* |
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 @@ | ||
{ | ||
"undef": false, | ||
"unused": true, | ||
"esversion": 6, | ||
"curly": true, | ||
"strict": "global", | ||
"globals": { | ||
"alert": true, | ||
"django": true, | ||
"gettext": true, | ||
"_": true | ||
}, | ||
"browser": true | ||
} |
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,19 @@ | ||
{ | ||
"rules": { | ||
"block-no-empty": null, | ||
"color-no-invalid-hex": true, | ||
"comment-empty-line-before": ["always", { | ||
"ignore": ["stylelint-commands", "after-comment"] | ||
}], | ||
"declaration-colon-space-after": "always", | ||
"indentation": [2, { | ||
"except": ["value"] | ||
}], | ||
"max-empty-lines": 4, | ||
"rule-empty-line-before": ["never-multi-line", { | ||
"except": ["first-nested"], | ||
"ignore": ["after-comment", "inside-block"] | ||
}], | ||
"unit-whitelist": ["em", "rem", "%", "s", "px", "vh", "deg"] | ||
} | ||
} |
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,33 @@ | ||
language: python | ||
cache: pip | ||
dist: focal | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- sqlite3 | ||
|
||
python: | ||
- "3.7" | ||
- "3.8" | ||
|
||
env: | ||
- DJANGO="django~=3.1" | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
before_install: | ||
- npm install -g jshint | ||
|
||
install: | ||
- pip install -U -e .[test] | ||
- pip install $DJANGO | ||
|
||
script: | ||
- ./run-qa-checks | ||
- coverage run --source=flat_json_widget runtests.py | ||
|
||
after_success: | ||
coveralls |
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,7 @@ | ||
Changelog | ||
========= | ||
|
||
Version 0.1.0 [unreleased] | ||
-------------------------- | ||
|
||
WIP |
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,27 @@ | ||
Copyright (c) 2020, Federico Capoano | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of django-loci, openwisp nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,9 @@ | ||
include LICENSE | ||
include README.rst | ||
include CHANGES.rst | ||
include requirements.txt | ||
recursive-include flat_json_widget * | ||
recursive-exclude * *.pyc | ||
recursive-exclude * *.swp | ||
recursive-exclude * __pycache__ | ||
recursive-exclude * *.db |
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,157 @@ | ||
django-flat-json-widget | ||
======================= | ||
|
||
.. image:: https://travis-ci.org/openwisp/django-flat-json-widget.svg | ||
:target: https://travis-ci.org/openwisp/django-flat-json-widget | ||
:alt: CI build status | ||
|
||
.. image:: https://coveralls.io/repos/openwisp/django-flat-json-widget/badge.svg | ||
:target: https://coveralls.io/r/openwisp/django-flat-json-widget | ||
:alt: Test Coverage | ||
|
||
.. image:: https://requires.io/github/openwisp/django-flat-json-widget/requirements.svg?branch=master | ||
:target: https://requires.io/github/openwisp/django-flat-json-widget/requirements/?branch=master | ||
:alt: Requirements Status | ||
|
||
.. image:: https://img.shields.io/gitter/room/nwjs/nw.js.svg | ||
:target: https://gitter.im/openwisp/general | ||
:alt: Chat | ||
|
||
.. image:: https://badge.fury.io/py/django-flat-json-widget.svg | ||
:target: http://badge.fury.io/py/django-flat-json-widget | ||
:alt: Pypi Version | ||
|
||
.. image:: https://pepy.tech/badge/django-flat-json-widget | ||
:target: https://pepy.tech/project/django-flat-json-widget | ||
:alt: Downloads | ||
|
||
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg | ||
:target: https://pypi.org/project/black/ | ||
:alt: code style: black | ||
|
||
------------ | ||
|
||
If you ever needed to store a flexible dictionary of key/value in your django models, | ||
you may have felt the need of giving your users a widget to easily manipulate | ||
the data by adding or removing rows, instead of having to edit the raw JSON. | ||
|
||
This package solves exactly that problem: it offers a widget to manipulate | ||
a flat JSON object made of simple keys and values. | ||
|
||
Compatibility | ||
------------- | ||
|
||
Tested on python >= 3.7 and Django >= 3.0. | ||
|
||
It should work also on previous versions of Django. | ||
|
||
Install stable version from pypi | ||
-------------------------------- | ||
|
||
Install from pypi: | ||
|
||
.. code-block:: shell | ||
pip install django-flat-json-widget | ||
Usage | ||
----- | ||
|
||
Add ``flat_json_widget`` to ``INSTALLED_APPS``: | ||
|
||
.. code-block:: python | ||
INSTALLED_APPS = [ | ||
# other apps... | ||
'flat_json_widget', | ||
] | ||
Then load the widget where you need it, for example, here's how to use it in the | ||
django admin site: | ||
|
||
.. code-block:: python | ||
from django.contrib import admin | ||
from django import forms | ||
from .models import JsonDocument | ||
from flat_json_widget import FlatJsonWidget | ||
class JsonDocumentForm(forms.ModelForm): | ||
class Meta: | ||
widgets = { | ||
'content': FlatJsonWidget | ||
} | ||
@admin.register(JsonDocument) | ||
class JsonDocumentAdmin(admin.ModelAdmin): | ||
list_display = ['name'] | ||
form = JsonDocumentForm | ||
Installing for development | ||
-------------------------- | ||
|
||
Install your forked repo: | ||
|
||
.. code-block:: shell | ||
git clone git://github.com/<your_fork>/django-flat-json-widget | ||
cd django-flat-json-widget/ | ||
python setup.py develop | ||
Install development dependencies: | ||
|
||
.. code-block:: shell | ||
pip install -e .[test] | ||
npm install -g jslint | ||
Create database: | ||
|
||
.. code-block:: shell | ||
cd tests/ | ||
./manage.py migrate | ||
./manage.py createsuperuser | ||
Launch development server: | ||
|
||
.. code-block:: shell | ||
./manage.py runserver 0.0.0.0:8000 | ||
You can access the admin interface at http://127.0.0.1:8000/admin/. | ||
|
||
Run tests with: | ||
|
||
.. code-block:: shell | ||
./runtests.py | ||
Run quality assurance tests with: | ||
|
||
.. code-block:: shell | ||
./run-qa-checks | ||
Contributing | ||
------------ | ||
|
||
Please refer to the `OpenWISP contributing guidelines <http://openwisp.io/docs/developer/contributing.html>`_. | ||
|
||
Changelog | ||
--------- | ||
|
||
See `CHANGES <https://github.com/openwisp/django-flat-json-widget/blob/master/CHANGES.rst>`_. | ||
|
||
License | ||
------- | ||
|
||
See `LICENSE <https://github.com/openwisp/django-flat-json-widget/blob/master/LICENSE>`_. | ||
|
||
Support | ||
------- | ||
|
||
See `OpenWISP Support Channels <http://openwisp.org/support.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,20 @@ | ||
from .widgets import FlatJsonWidget # noqa | ||
|
||
VERSION = (0, 1, 0, 'alpha') | ||
__version__ = VERSION # alias | ||
|
||
|
||
def get_version(): # pragma: no cover | ||
version = '%s.%s' % (VERSION[0], VERSION[1]) | ||
if VERSION[2]: | ||
version = '%s.%s' % (version, VERSION[2]) | ||
if VERSION[3:] == ('alpha', 0): | ||
version = '%s pre-alpha' % version | ||
else: | ||
if VERSION[3] != 'final': | ||
try: | ||
rev = VERSION[4] | ||
except IndexError: | ||
rev = 0 | ||
version = '%s%s%s' % (version, VERSION[3][0:1], rev) | ||
return version |
Oops, something went wrong.