Skip to content

Commit 9ca2aa1

Browse files
authored
Merge pull request #3 from davidslusser/docs
updated docs; fix model bug; rearranged project layout
2 parents a47c18a + af1102d commit 9ca2aa1

File tree

19 files changed

+45
-29
lines changed

19 files changed

+45
-29
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include README.md
22
include requirements.txt
33
include setup.py
4-
graft src/signalcontrol
4+
graft signalcontrol
55
global-exclude *.py[co]
File renamed without changes.

docs/source/about.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
About
55
=====
66
django-signalcontrol is a reusable django application that adds dynamic control to model signals.
7-
With signal_control added to a model signal, an entry for the signal is added to the SignalControl table that includes
8-
a boolean field to enable/disable the signal. An interface in the django admin console is provided to enable or disable
9-
signals individually or in bulk. When a signal is disabled it will not execute when dispatched through the receiver,
10-
such as post_save.
7+
8+
9+
With signal_control added to a model signal, the signal can by enabled (default) or disabled from the django admin.
10+
An entry for the signal is added to the SignalControl table that includes a boolean field to enable/disable the signal.
11+
When a signal is disabled it will not execute when dispatched through the receiver, such as post_save.
1112

1213
See details on django-extensions features on the :ref:`Features <features>` page
1314

docs/source/features.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,30 @@ Features
77
This document details the features currently available in django-signalcontrol.
88

99

10+
Signal Detection
11+
----------------
12+
Model signals are detected automatically when django starts. Any model signal with signal_control applied will be
13+
detected and automatically added (if not already present) in the SignalControl database table. An info message will be
14+
printed when django starts if a new signal with signal_control is discovered. It will look like this:
1015

11-
signal_control decorator
12-
------------------------
16+
``INFO: registering msg_after_my_model_save in demo with SignalControl``
17+
18+
In this example, 'msg_after_my_model_save' is the name of the signal, and 'demo' is the name of the django app.
19+
20+
21+
The signal_control Decorator
22+
----------------------------
1323

1424
SignalControl can be added to a model signal via a provided decorator. In the signal.py file, import the signalcontrol
15-
decorator and add to the line directly above the signal definition.
25+
decorator and add the signal_control decorator to the line directly above the signal definition. Example:
1626

1727
.. code-block:: python
1828
1929
from signalcontrol.decorators import signal_control
2030
2131
@receiver(post_save, sender=MyCoolModel)
2232
@signal_control
23-
def msg_my_model_two(sender, instance, created, **kwargs):
33+
def msg_after_my_model_save(sender, instance, created, **kwargs):
2434
""" some signal """
2535
print("you just saved an instance of MyCoolModel")
2636
..
@@ -34,3 +44,5 @@ An django admin interface for django-signalcontrol is available to set model sig
3444
displays all model signals that can be controlled, and lists the application, model, signal receiver and signal name.
3545
Additionally, full search is available and filters are available for each field.
3646
Signals can be enabled or disabled individually or in bulk.
47+
48+
.. image:: images/django_admin.png

docs/source/images/django_admin.png

119 KB
Loading

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ Contents
1010

1111
about
1212
installation
13+
features
1314
version_history
1415
license

docs/source/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ To use django-signalcontrol in your project, add 'signalcontrol' to INSTALLED_AP
3131
Enabling signal control on a model signal
3232
-----------------------------------------
3333
SignalControl can be added to a model signal via a provided decorator. In the signal.py file, import the signalcontrol
34-
decorator and add to the line directly above the signal definition.
34+
decorator and add the signal_control decorator to the line directly above the signal definition. Example:
3535

3636
.. code-block:: python
3737
3838
from signalcontrol.decorators import signal_control
3939
4040
@receiver(post_save, sender=MyCoolModel)
4141
@signal_control
42-
def msg_my_model_two(sender, instance, created, **kwargs):
42+
def msg_after_my_model_save(sender, instance, created, **kwargs):
4343
""" some signal """
4444
print("you just saved an instance of MyCoolModel")
4545
..

docs/source/version_history.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
Version History
55
===============
66

7-
8-
Pre-Release
9-
-----------
10-
117
.. csv-table::
128
:header: "Release", "Details"
139
:widths: 20, 100
1410

11+
"0.0.3", "bug fixes and project structure updates"
1512
"0.0.2", "added documentation"
1613
"0.0.1", "initial release"
14+
15+
16+
Source Code
17+
-----------
18+
19+
Source code for django-signalcontrol is available on github: https://github.com/davidslusser/django-signalcontrol/

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
django>=2.2.9,<3.0
1+
django>=2.2.0

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
2-
from setuptools import setup, find_packages
3-
from src import signalcontrol
2+
from setuptools import setup
3+
import signalcontrol
44

55
with open(os.path.join(os.path.dirname(__file__), 'README.md'), encoding='utf-8') as readme:
66
README = readme.read()
@@ -15,8 +15,7 @@
1515
description='A django app to allow dynamic control of signals',
1616
long_description=README,
1717
long_description_content_type='text/markdown',
18-
packages=find_packages(),
19-
include_package_data=True,
18+
packages=['signalcontrol'],
2019
version=version,
2120
license=signalcontrol.__license__,
2221
author=signalcontrol.__author__,

src/signalcontrol/__init__.py renamed to signalcontrol/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"""
88

99
__title__ = 'django-signalcontrol'
10-
__version__ = '0.0.2'
10+
__version__ = '0.0.3'
1111
__author__ = 'David Slusser'
1212
__email__ = 'dbslusser@gmail.com'
1313
__license__ = 'GPL-3.0'
1414
__copyright__ = 'Copyright 2020 David Slusser'
1515

1616

17-
default_app_config = 'src.signalcontrol.apps.SignalControlConfig'
17+
default_app_config = 'signalcontrol.apps.SignalControlConfig'
File renamed without changes.

src/signalcontrol/apps.py renamed to signalcontrol/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55

66
class SignalControlConfig(AppConfig):
7-
name = 'src.signalcontrol'
7+
name = 'signalcontrol'
88
verbose_name = "Signal Control"
File renamed without changes.

src/signalcontrol/migrations/0001_initial.py renamed to signalcontrol/migrations/0001_initial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 2.2.12 on 2020-04-18 20:57
1+
# Generated by Django 2.2.12 on 2020-04-20 21:41
22

33
from django.db import migrations, models
44

@@ -15,7 +15,7 @@ class Migration(migrations.Migration):
1515
name='SignalControl',
1616
fields=[
1717
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18-
('app_name', models.CharField(max_length=32, unique=True)),
18+
('app_name', models.CharField(max_length=32)),
1919
('model_name', models.CharField(max_length=128)),
2020
('signal_name', models.CharField(max_length=255)),
2121
('signal_type', models.CharField(max_length=32)),

signalcontrol/migrations/__init__.py

Whitespace-only changes.

src/signalcontrol/models.py renamed to signalcontrol/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class SignalControl(models.Model):
55
""" table to track status of a signal used in the signal_control decorator """
6-
app_name = models.CharField(max_length=32, unique=True)
6+
app_name = models.CharField(max_length=32)
77
model_name = models.CharField(max_length=128)
88
signal_name = models.CharField(max_length=255)
99
signal_type = models.CharField(max_length=32)

src/signal_control_tests/signalcontrol/migrations/0001_initial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 2.2.12 on 2020-04-18 20:57
1+
# Generated by Django 2.2.12 on 2020-04-20 21:41
22

33
from django.db import migrations, models
44

@@ -15,7 +15,7 @@ class Migration(migrations.Migration):
1515
name='SignalControl',
1616
fields=[
1717
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18-
('app_name', models.CharField(max_length=32, unique=True)),
18+
('app_name', models.CharField(max_length=32)),
1919
('model_name', models.CharField(max_length=128)),
2020
('signal_name', models.CharField(max_length=255)),
2121
('signal_type', models.CharField(max_length=32)),

src/signal_control_tests/signalcontrol/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class SignalControl(models.Model):
55
""" table to track status of a signal used in the signal_control decorator """
6-
app_name = models.CharField(max_length=32, unique=True)
6+
app_name = models.CharField(max_length=32)
77
model_name = models.CharField(max_length=128)
88
signal_name = models.CharField(max_length=255)
99
signal_type = models.CharField(max_length=32)

0 commit comments

Comments
 (0)