Skip to content

Commit

Permalink
Remove integrations from base (#69)
Browse files Browse the repository at this point in the history
* Removing workflows, pagerduty and statuspage as they'll become recipes/plugins in future.
  • Loading branch information
evnsio authored and milesbxf committed Aug 15, 2019
1 parent c2526e0 commit 81e389e
Show file tree
Hide file tree
Showing 32 changed files with 59 additions and 671 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ REST_FRAMEWORK = {
# or allow read-only access for unauthenticated users.
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated"],
}
#
#
# Markdown Filter
Expand Down Expand Up @@ -154,13 +154,6 @@ See the demo app for an example of how to get the incident channel ID from the S
We want to invite the Bot to all Incident Channels, so need to know its ID.

- The default bot name is `incident` - change the `INCIDENT_BOT_NAME` if your app uses something different.

### Database encrypted field key(`ENCRYPTED_FIELD_KEY`)

Used to encrypt potentially sensitive values stored in the database for workflows.

- This can be any value but keep it secure and don't lose it. You will be unable to decrypt values from the database without it.

---

# Development
Expand Down
6 changes: 0 additions & 6 deletions demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ We want to invite the Bot to all Incident Channels, so need to know its ID.

- The default bot name is `incident` - change the `INCIDENT_BOT_NAME` if your app uses something different.

### Database encrypted field key(`ENCRYPTED_FIELD_KEY`)

Used to encrypt potentially sensitive values stored in the database for workflows.

- This can be any value but keep it secure and don't lose it. You will be unable to decrypt values from the database without it.

## 3. Run Response

From the root of the Response directory run:
Expand Down
2 changes: 1 addition & 1 deletion demo/demo/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

USE_L10N = True

USE_TZ = True
USE_TZ = False


# Static files (CSS, JavaScript, Images)
Expand Down
1 change: 0 additions & 1 deletion response/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib import admin

from .core import admin
from .pagerduty import admin
from .slack import admin
15 changes: 6 additions & 9 deletions response/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ class ResponseConfig(AppConfig):

def ready(self):
from .slack import (settings,
signals,
action_handlers,
event_handlers,
incident_commands,
incident_notifications,
dialog_handlers,
workflows)
if settings.PAGERDUTY_ENABLED:
from .slack.workflows import pagerduty
signals,
action_handlers,
event_handlers,
incident_commands,
incident_notifications,
dialog_handlers)
49 changes: 2 additions & 47 deletions response/core/urls.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,7 @@
from django.conf.urls import url, include
from rest_framework import routers, viewsets, pagination
from rest_framework.decorators import action
from rest_framework import routers

from response.core.models.incident import Incident
from response.core.models.action import Action
from response.core.models.user_external import ExternalUser

from datetime import datetime
from calendar import monthrange

from response.core.serializers import *

class ExternalUserViewSet(viewsets.ModelViewSet):
# ViewSets define the view behavior.
queryset = ExternalUser.objects.all()
serializer_class = ExternalUserSerializer


class ActionViewSet(viewsets.ModelViewSet):
# ViewSets define the view behavior.
queryset = Action.objects.all()
serializer_class = ActionSerializer


# Will return the incidents of the current month
# Can pass ?start=2019-05-28&end=2019-06-03 to change range
class IncidentViewSet(viewsets.ModelViewSet):
# ViewSets define the view behavior.

serializer_class = IncidentSerializer
pagination_class = None # Remove pagination

def get_queryset(self):
# Same query is used to get single items so we check if pk is passed
# incident/2/ if we use the filter below we would have to have correct time range
if 'pk' in self.kwargs:
return Incident.objects.filter(pk=self.kwargs['pk'])

today = datetime.today()
first_day_of_current_month = datetime(today.year, today.month, 1)
days_in_month = monthrange(today.year, today.month)[1]
last_day_of_current_month = datetime(today.year, today.month, days_in_month)

start = self.request.GET.get('start', first_day_of_current_month)
end = self.request.GET.get('end', last_day_of_current_month)

return Incident.objects.filter(start_time__gte=start, start_time__lte=end)
from response.core.views import IncidentViewSet, ActionViewSet, ExternalUserViewSet

# Routers provide an easy way of automatically determining the URL conf.
router = routers.DefaultRouter()
Expand All @@ -57,5 +13,4 @@ def get_queryset(self):
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
url(r'^', include(router.urls)),
#url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]
47 changes: 45 additions & 2 deletions response/core/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
from django.shortcuts import render
from rest_framework import viewsets

# Create your views here.
from response.core.models.incident import Incident
from response.core.models.action import Action
from response.core.models.user_external import ExternalUser
from response.core.serializers import ExternalUserSerializer, ActionSerializer, IncidentSerializer

from datetime import datetime
from calendar import monthrange


class ExternalUserViewSet(viewsets.ModelViewSet):
# ViewSets define the view behavior.
queryset = ExternalUser.objects.all()
serializer_class = ExternalUserSerializer


class ActionViewSet(viewsets.ModelViewSet):
# ViewSets define the view behavior.
queryset = Action.objects.all()
serializer_class = ActionSerializer


# Will return the incidents of the current month
# Can pass ?start=2019-05-28&end=2019-06-03 to change range
class IncidentViewSet(viewsets.ModelViewSet):
# ViewSets define the view behavior.

serializer_class = IncidentSerializer
pagination_class = None # Remove pagination

def get_queryset(self):
# Same query is used to get single items so we check if pk is passed
# incident/2/ if we use the filter below we would have to have correct time range
if 'pk' in self.kwargs:
return Incident.objects.filter(pk=self.kwargs['pk'])

today = datetime.today()
first_day_of_current_month = datetime(today.year, today.month, 1)
days_in_month = monthrange(today.year, today.month)[1]
last_day_of_current_month = datetime(today.year, today.month, days_in_month)

start = self.request.GET.get('start', first_day_of_current_month)
end = self.request.GET.get('end', last_day_of_current_month)

return Incident.objects.filter(start_time__gte=start, start_time__lte=end)
30 changes: 1 addition & 29 deletions response/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Generated by Django 2.2.3 on 2019-07-12 11:24
# Generated by Django 2.2.3 on 2019-07-19 10:27

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.db.models.fields
import response.slack.models.workflow


class Migration(migrations.Migration):
Expand All @@ -23,15 +21,6 @@ class Migration(migrations.Migration):
('channel_id', models.CharField(max_length=20)),
],
),
migrations.CreateModel(
name='Escalation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, unique=True)),
('summary', models.TextField(max_length=1000)),
('escalation_policy', models.CharField(max_length=10)),
],
),
migrations.CreateModel(
name='ExternalUser',
fields=[
Expand Down Expand Up @@ -60,23 +49,6 @@ class Migration(migrations.Migration):
('reporter', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='reporter', to='response.ExternalUser')),
],
),
migrations.CreateModel(
name='Workflow',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('enabled', models.BooleanField(default=False)),
('name', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='WorkflowParameters',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('value', response.slack.models.workflow.EncryptedField(blank=True, field_type=django.db.models.fields.CharField, max_length=500, null=True)),
('workflow', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='parameters', to='response.Workflow')),
],
),
migrations.CreateModel(
name='PinnedMessage',
fields=[
Expand Down
1 change: 0 additions & 1 deletion response/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.db import models

from .core.models import *
from .pagerduty.models import *
from .slack.models import *
53 changes: 0 additions & 53 deletions response/pagerduty/README.md

This file was deleted.

Empty file removed response/pagerduty/__init__.py
Empty file.
6 changes: 0 additions & 6 deletions response/pagerduty/admin.py

This file was deleted.

34 changes: 0 additions & 34 deletions response/pagerduty/incident.py

This file was deleted.

10 changes: 0 additions & 10 deletions response/pagerduty/models.py

This file was deleted.

3 changes: 0 additions & 3 deletions response/pagerduty/views.py

This file was deleted.

3 changes: 1 addition & 2 deletions response/slack/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from response.slack.models import HeadlinePost, CommsChannel, Notification, UserStats, PinnedMessage, Workflow, WorkflowAdmin
from response.slack.models import HeadlinePost, CommsChannel, Notification, UserStats, PinnedMessage


# Register your models here.
Expand All @@ -8,4 +8,3 @@
admin.site.register(Notification)
admin.site.register(UserStats)
admin.site.register(PinnedMessage)
admin.site.register(Workflow, WorkflowAdmin)
Loading

0 comments on commit 81e389e

Please sign in to comment.