-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Implement sender whitelist filters #132
* senders with no filters will allow everything to pass * senders with filters enabled will check labels for whitelist
- Loading branch information
Showing
24 changed files
with
334 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Generated by Django 2.1.2 on 2019-03-06 06:20 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('promgen', '0006_exporter_options'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Filter', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=128)), | ||
('value', models.CharField(max_length=128)), | ||
], | ||
options={ | ||
'ordering': ('sender', 'name', 'value'), | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='filter', | ||
name='sender', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='promgen.Sender'), | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='filter', | ||
unique_together={('sender', 'name', 'value')}, | ||
), | ||
] |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% extends "base.html" %} | ||
{% load i18n %} | ||
{% load promgen %} | ||
{% block content %} | ||
|
||
|
||
<div class="page-header"> | ||
<h1>{{object|klass}}: {{object.name}}</h1> | ||
</div> | ||
|
||
{% breadcrumb object 'Update Notifier' %} | ||
|
||
<table class="table table-bordered table-condensed{% if collapse %} collapse" id="{{ collapse }}{% endif %}"> | ||
<tr> | ||
<th>Notifier</th> | ||
<th>Value</th> | ||
<th>Filters</th> | ||
<th>Actions</th> | ||
</tr> | ||
{% include 'promgen/sender_row.html' with notifier=object show_edit=1 %} | ||
</table> | ||
|
||
{% endblock %} |
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,43 @@ | ||
{% load i18n %} | ||
<tr> | ||
<td title="Added by: {{notifier.owner}}">{{ notifier.sender }}</td> | ||
<td>{{ notifier.show_value }}</td> | ||
<td> | ||
{% for f in notifier.filter_set.all %} | ||
<form method="post" action="{% url 'notifier-edit' notifier.id %}" onsubmit="return confirm('Delete this filter?')" style="display: inline"> | ||
{% csrf_token %} | ||
<input name="next" type="hidden" value="{{ request.get_full_path }}" /> | ||
<input name="filter.pk" value="{{f.id}}" type="hidden" /> | ||
<button class="label label-primary" style="display: inline-block;"> | ||
{{f.name}}:{{f.value}} | ||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> | ||
</button> | ||
</form> | ||
{% endfor %} | ||
|
||
<button class="btn btn-primary btn-xs" data-toggle="collapse" data-target="#notifierLabel{{notifier.id}}">+</button> | ||
<div class="collapse" id="notifierLabel{{notifier.id}}"> | ||
<form method="post" action="{% url 'notifier-edit' notifier.id %}" style="display: inline"> | ||
{% csrf_token %} | ||
<input name="next" type="hidden" value="{{ request.get_full_path }}" /> | ||
<input name="filter.name" placeholder="name" required list="common.labels" @change="setTargetList($event, 'newLabel{{notifier.id}}')"> | ||
<input name="filter.value" placeholder="value" required id="newLabel{{notifier.id}}"> | ||
<button class="btn btn-primary btn-xs">Submit</button> | ||
</form> | ||
</div> | ||
</td> | ||
{% if show_edit %} | ||
<td> | ||
<a href="{% url 'notifier-edit' notifier.id %}" class="btn btn-warning btn-xs">{% trans "Edit" %}</a> | ||
<form method="post" action="{% url 'notifier-test' notifier.id %}" style="display: inline"> | ||
{% csrf_token %} | ||
<input name="next" type="hidden" value="{{ request.get_full_path }}" /> | ||
<button class="btn btn-info btn-xs">{% trans "Test" %}</button> | ||
</form> | ||
<form method="post" action="{% url 'notifier-delete' notifier.id %}" onsubmit="return confirm('{% trans "Delete notificiation?" %}')" style="display: inline"> | ||
{% csrf_token %} | ||
<button class="btn btn-danger btn-xs">{% trans "Delete" %}</button> | ||
</form> | ||
</td> | ||
{% endif %} | ||
</tr> |
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
Oops, something went wrong.