Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion threebot_hook/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations

Expand Down
37 changes: 37 additions & 0 deletions threebot_hook/migrations/0001_initial.py.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.CreateModel(
name='Hook',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('slug', models.SlugField(max_length=255)),
('user', models.CharField(max_length=255, null=True, blank=True)),
('repo', models.CharField(max_length=255, null=True, blank=True)),
('secret', models.CharField(max_length=255, null=True, blank=True)),
('owner', models.ForeignKey(blank=True, to='organizations.Organization', null=True)),
('param_list', models.ForeignKey(to='threebot.ParameterList')),
('worker', models.ForeignKey(to='threebot.Worker')),
('workflow', models.ForeignKey(to='threebot.Workflow')),
],
options={
'db_table': 'threebot_hook',
'verbose_name': 'Hook',
'verbose_name_plural': 'Hooks',
},
bases=(models.Model,),
),
migrations.AlterUniqueTogether(
name='hook',
unique_together=set([('workflow', 'worker', 'param_list')]),
),
]
2 changes: 1 addition & 1 deletion threebot_hook/migrations/0002_remove_hook_owner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations

Expand Down
18 changes: 18 additions & 0 deletions threebot_hook/migrations/0002_remove_hook_owner.py.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('threebot_hook', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='hook',
name='owner',
),
]
4 changes: 2 additions & 2 deletions threebot_hook/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
class Hook(models.Model):
slug = models.SlugField(max_length=255)
user = models.CharField(max_length=255, blank=True, null=True)
repo = models.CharField(max_length=255, blank=True, null=True, help_text=u'Leave blank. Field is not used in the current version.')
secret = models.CharField(max_length=255, blank=True, null=True, help_text=u'Leave blank. Field is not used in the current version.')
repo = models.CharField(max_length=255, blank=True, null=True, help_text='Leave blank. Field is not used in the current version.')
secret = models.CharField(max_length=255, blank=True, null=True, help_text='Leave blank. Field is not used in the current version.')
workflow = models.ForeignKey(Workflow)
worker = models.ForeignKey(Worker)
param_list = models.ForeignKey(ParameterList)
Expand Down
45 changes: 45 additions & 0 deletions threebot_hook/models.py.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django import dispatch
from django.contrib.sites.models import Site

from rest_framework.authtoken.models import Token

from threebot.models import Workflow
from threebot.models import Worker
from threebot.models import ParameterList


@python_2_unicode_compatible
class Hook(models.Model):
slug = models.SlugField(max_length=255)
user = models.CharField(max_length=255, blank=True, null=True)
repo = models.CharField(max_length=255, blank=True, null=True, help_text=u'Leave blank. Field is not used in the current version.')
secret = models.CharField(max_length=255, blank=True, null=True, help_text=u'Leave blank. Field is not used in the current version.')
workflow = models.ForeignKey(Workflow)
worker = models.ForeignKey(Worker)
param_list = models.ForeignKey(ParameterList)

def get_hook_url(self):
return "%d-%d-%d-%s" % (self.workflow.id, self.worker.id, self.param_list.id, self.slug)

def __str__(self):
return "%s (%d)" % (self.get_hook_url(), self.pk)

def make_full_url(self, user):
token, created = Token.objects.get_or_create(user=user)
return "https://%s/hooks/%s/%s-%s-%s/" % (Site.objects.get_current().domain, token, self.workflow.id, self.worker.id, self.param_list.id)

class Meta():
verbose_name = _("Hook")
verbose_name_plural = _("Hooks")
db_table = 'threebot_hook'
unique_together = ("workflow", "worker", "param_list")


class HookSignal(dispatch.Signal):
pass

pre_hook_signal = HookSignal()
post_hook_signal = HookSignal()