This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Receiver of
raw_hook_event
now uses the same logic as receivers of …
…other Should fix #58 Some backward incompatible changes were introduced (see README.md)
- Loading branch information
Showing
14 changed files
with
326 additions
and
115 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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
-r devrequirements.txt | ||
django-contrib-comments>=1.6.1 | ||
django-contrib-comments>=1.6.1,<1.7.0 | ||
Django>=1.8,<1.9 |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
-r devrequirements.txt | ||
django-contrib-comments>=1.6.2 | ||
django-contrib-comments>=1.6.2,<1.7.0 | ||
Django>=1.9,<1.10 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = (1, 5, 0) | ||
VERSION = (1, 6, 0) |
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 |
---|---|---|
@@ -1,34 +1,39 @@ | ||
from django.contrib import admin | ||
from django.conf import settings | ||
from django import forms | ||
from rest_hooks.models import Hook | ||
from rest_hooks.utils import get_hook_model | ||
|
||
|
||
HOOK_EVENTS = getattr(settings, 'HOOK_EVENTS', None) | ||
if HOOK_EVENTS is None: | ||
if getattr(settings, 'HOOK_EVENTS', None) is None: | ||
raise Exception("You need to define settings.HOOK_EVENTS!") | ||
|
||
|
||
HookModel = get_hook_model() | ||
|
||
|
||
class HookForm(forms.ModelForm): | ||
""" | ||
Model form to handle registered events, asuring | ||
only events declared on HOOK_EVENTS settings | ||
can be registered. | ||
""" | ||
ADMIN_EVENTS = [(x, x) for x in HOOK_EVENTS.keys()] | ||
|
||
class Meta: | ||
model = Hook | ||
model = HookModel | ||
fields = ['user', 'target', 'event'] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(HookForm, self).__init__(*args, **kwargs) | ||
self.fields['event'] = forms.ChoiceField(choices=self.ADMIN_EVENTS) | ||
self.fields['event'] = forms.ChoiceField(choices=self.get_admin_events()) | ||
|
||
@classmethod | ||
def get_admin_events(cls): | ||
return [(x, x) for x in getattr(settings, 'HOOK_EVENTS', None).keys()] | ||
|
||
|
||
class HookAdmin(admin.ModelAdmin): | ||
list_display = [f.name for f in Hook._meta.fields] | ||
list_display = [f.name for f in HookModel._meta.fields] | ||
raw_id_fields = ['user', ] | ||
form = HookForm | ||
|
||
admin.site.register(Hook, HookAdmin) | ||
|
||
admin.site.register(HookModel, HookAdmin) |
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
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,18 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rest_hooks', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name='Hook', | ||
options={ | ||
'swappable': 'HOOK_CUSTOM_MODEL', | ||
}, | ||
), | ||
] |
Oops, something went wrong.