Skip to content

Commit

Permalink
Init django-chartjs project
Browse files Browse the repository at this point in the history
  • Loading branch information
Natim committed Jun 11, 2013
0 parents commit 0224da8
Show file tree
Hide file tree
Showing 17 changed files with 223 additions and 0 deletions.
5 changes: 5 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
########################
Authors and contributors
########################

* Rémy Hubscher <[email protected]>, <[email protected]>
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Changelog
=========

0.1 (unreleased)
----------------
33 changes: 33 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#######
License
#######

Copyright (c) 2013 Rémy HUBSCHER <[email protected]>

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 the copyright holder 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
OWNER 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.
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
recursive-include chartjs *
global-exclude *.pyc
include *.txt
include VERSION README.rst CHANGELOG LICENSE INSTALL AUTHORS
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.PHONY: docs test clean

bin/python:
virtualenv .
bin/python setup.py develop

test: bin/python
bin/pip install tox
bin/tox

clean:
rm -rf bin .tox include/ lib/ man/ django_chartjs.egg-info/ build/
36 changes: 36 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
###############
Django Chart.js
###############

Django Chart.js lets you manage charts in you Django application.

Using a set of predefined Class Based Views your are able to get
started after writting just your SQL query.

* Authors: Rémy Hubscher and `contributors
<https://github.com/novagile/django-chartjs/graphs/contributors>`_
* Licence: BSD
* Compatibility: Django 1.5+, python2.7 up to python3.3
* Project URL: https://github.com/novagile/django-i18nurl


Getting Started
===============

Install django-chartjs::

pip install django-chartjs


Add it to your ``INSTALLED_APPS`` settings::

INSTALLED_APPS = (
'...',
'chartjs',
)


Using it
========

Look at the demo project :D
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1dev
Empty file added chartjs/__init__.py
Empty file.
Empty file added chartjs/models.py
Empty file.
39 changes: 39 additions & 0 deletions chartjs/static/js/Chart.min.js

Large diffs are not rendered by default.

Empty file added chartjs/views/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions chartjs/views/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
import json
from django import http


class JSONResponseMixin(object):
def render_to_response(self, context):
"Returns a JSON response containing 'context' as payload"
return self.get_json_response(self.convert_context_to_json(context))

def get_json_response(self, content, **httpresponse_kwargs):
"Construct an `HttpResponse` object."
return http.HttpResponse(content,
content_type='application/json',
**httpresponse_kwargs)

def convert_context_to_json(self, context):
"Convert the context dictionary into a JSON object"
# Note: This is *EXTREMELY* naive; in reality, you'll need
# to do much more complex handling to ensure that arbitrary
# objects -- such as Django model instances or querysets
# -- can be serialized as JSON.
return json.dumps(context)
7 changes: 7 additions & 0 deletions chartjs/views/lines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
"""Tools to build Line charts parameters."""
from .base import JSONResponseMixin


class BaseLineChart(JSONResponseMixin):
pass
37 changes: 37 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from os.path import abspath, dirname, join
from setuptools import find_packages, setup


def read_relative_file(filename):
"""Returns contents of the given file, whose path is supposed relative
to this module."""
with open(join(dirname(abspath(__file__)), filename)) as f:
return f.read()


if __name__ == '__main__': # ``import setup`` doesn't trigger setup().
setup(name='django-chartjs',
version=read_relative_file('VERSION').strip(),
description="Django Chart.js ajax views",
long_description=read_relative_file('README.rst'),
classifiers=['Development Status :: 3 - Alpha',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
],
keywords='django chart chartjs ajax class based views',
author='Rémy Hubscher',
author_email='[email protected]',
url='https://github.com/novagile/django-chartjs',
license='BSD Licence',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=[] # depends on Django
)
5 changes: 5 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
python setup.py develop
(cd demo; python setup.py develop)
demo test demoproject
flake8 i18nurl
13 changes: 13 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tox]
envlist = py27

[testenv]
commands =
./test.sh
deps =
Django
flake8
django-nose
coverage
nose
rednose
3 changes: 3 additions & 0 deletions update-Chart.js.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -x

wget -O chartjs/static/js/Chart.min.js https://raw.github.com/nnnick/Chart.js/master/Chart.min.js

0 comments on commit 0224da8

Please sign in to comment.