Skip to content

Commit

Permalink
fixes to setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
asifpy committed Mar 24, 2016
1 parent 97fa203 commit a993292
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__/
*.pyc
build
dist
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ script:
- coverage run --source=crudbuilder runtests.py
env:
matrix:
- DJANGO="1.7.11"
- DJANGO="1.7.4"
- DJANGO="1.8.2"
- DJANGO="1.9.2"
matrix:
exclude:
- python: "3.5"
env: DJANGO="1.7.11"
env: DJANGO="1.7.4"
# Django 1.9+ no longer supports python 3.2/3.3
- python: "3.3"
env: DJANGO="1.9.2"

install:
- pip install -q Django==$DJANGO
- python setup.py -q install
- pip install django-tables2==1.1.2
- if [[ $DJANGO == '1.7.4' ]]; then pip install "django-tables2==1.1.2" else pip install "django-tables2"; fi
- pip install coveralls
after_success:
coveralls
3 changes: 0 additions & 3 deletions crudbuilder/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,3 @@ def auto_discover():
for app in settings.INSTALLED_APPS:
import_crud(app)


if __name__ == '__main__':
print (plural('activity'))
60 changes: 58 additions & 2 deletions docs/source/signals.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
Signals
=======

django-crudbuilder comes with two built-in signals to perform/execute specific actions after post create and post update views.
django-crudbuilder comes with built-in signals to perform/execute specific actions after post create and post update views.
You can able to access ``request`` and ``instance`` in your own handlers.

Usage of these signals you can view in `handlers of example project`_ on Github.

Following are the list of supported signals.::
post_create_signal --> runs after modelform.save() in CreateView
post_update_signal --> runs after modelform.save() in UpdateView
post_inline_create_signal --> runs after inlineformset.save() in CreateView
post_inline_update_signal --> runs after inlineformset.save() in UpdateView


post_create_signal
------------------
Expand Down Expand Up @@ -46,6 +55,53 @@ This signal will loaded/executed soon after the object gets updated for specific
instance.updated_by = request.user
instance.save()

Usage of these signals you can view in `handlers of example project`_ on Github.

post_inline_create_signal
-------------------------

This signal will get executed soon after the inline formset gets saved which means this get fires right after the ``inlineformset.save()`` method gets called in CreateView.::

# tutorial/handlers.py
from django.dispatch import receiver
from crudbuilder.signals import post_inline_create_signal

@receiver(post_inline_create_signal, sender=Person)
def post_inline_create_handler(sender, **kwargs):
request = kwargs['request']
parent = kwargs['parent']
children = kwargs['children']

parent.created_by = request.user
parent.save()

for child in children:
child.created_by = request.user
child.save()


post_inline_update_signal
-------------------------

This signal will get executed soon after the inline formset gets updated which means this get fires right after the ``inlineformset.save()`` method gets called in UpdateView.::

# tutorial/handlers.py
from django.dispatch import receiver
from crudbuilder.signals import post_inline_update_signal

@receiver(post_inline_update_signal, sender=Person)
def post_inline_update_handler(sender, **kwargs):
request = kwargs['request']
parent = kwargs['parent']
children = kwargs['children']

parent.updated_by = request.user
parent.save()

for child in children:
child.updated_by = request.user
child.save()




.. _handlers of example project: https://github.com/asifpy/django-crudbuilder/blob/master/example/example/handlers.py
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import os
from setuptools import setup
from django.utils import version
import crudbuilder

# Allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
djang_version = version.get_complete_version()[1]

if djang_version == 7:
django_tables2 = 'django_tables2>=1.0.4'
else:
django_tables2 = 'django_tables2'


def read(fname):
Expand All @@ -21,7 +28,7 @@ def read(fname):
author_email='saluasif@gmail.com',
long_description=read('README.rst'),
install_requires=[
'django_tables2>=1.0.4',
django_tables2,
'six>=1.10.0'
],
classifiers=[
Expand Down

0 comments on commit a993292

Please sign in to comment.