allow organization promises to be reflected on report

parent d5bb536e
......@@ -5,6 +5,7 @@
// Registry Sentry for error reporting
let sentry_token = document.head.querySelector("[name=sentry_token]").getAttribute('content');
let version = document.head.querySelector("[name=version]").getAttribute('content');
console.log(sentry_token)
if (sentry_token){
Raven.config(sentry_token, {release: version}).install();
}
......@@ -559,7 +560,8 @@ $(document).ready(function () {
urls: Array,
mailto: document.head.querySelector("[name=mailto]").getAttribute('content'),
selected: null,
loading: false
loading: false,
promises: false,
},
filters: {
// you cannot run filters in rawHtml, so this doesn't work.
......@@ -673,12 +675,14 @@ $(document).ready(function () {
vueReport.loading = true;
vueReport.name = null;
$.getJSON('/data/report/' + OrganizationID + '/' + weeks_ago, function (data) {
console.log(data)
vueReport.loading = false;
vueReport.urls = data.calculation["organization"]["urls"];
vueReport.points = data.rating;
vueReport.when = data.when;
vueReport.name = data.name;
vueReport.twitter_handle = data.twitter_handle;
vueReport.promises = data.promises;
// include id in anchor to allow url sharing
let newHash = 'report-' + OrganizationID;
$('a#report-anchor').attr('name', newHash)
......
......@@ -312,11 +312,15 @@
Dit resultaat delen? {% verbatim %}<span v-html="create_twitter_link(name, twitter_handle, points)"></span>{% endverbatim %}<br />
<br />
{% trans "Data from" %}: {% verbatim %}{{ humanize(when) }}{% endverbatim %}<br />
{% trans "Points" %}: {% verbatim %}{{ points }}{% endverbatim %}, {% trans "congratulations" %}!<br />
{% trans "Points" %}: {% verbatim %}{{ points }}{% endverbatim %}<span v-if="promises">*</span>, {% trans "congratulations" %}!
<br />
<br />
Gaat faalkaart niet ver genoeg? <a v-bind:href="'mailto:' + mailto + '?subject=Pentest%20aanvraag%20voor%20'+name+'&body=Beste Faalkaart,%0D%0A%0D%0AWij hebben interesse in een pentest op de outward-facing IT van onze organisatie. Kunnen jullie daar bij helpen?%0D%0A%0D%0AMet vriendelijke groet,%0D%0A%0D%0A'">Vraag hier een echte pentest aan.</a><br/>
Ontbreken er domeinen? <a v-bind:href="'mailto:' + mailto + '?subject=Nieuwe%20domeinen%20voor%20'+name+'&body=Beste Faalkaart,%0D%0A%0D%0AGraag de volgende domeinen toevoegen aan de kaart:%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0ATip: stuur een zonefile mee met alle domeinen.%0D%0A%0D%0AMet vriendelijke groet,%0D%0A%0D%0A'">Stuur hier domeinen in.</a><br/>
<br />
<div v-if="promises" id="promise">* Deze orgranisatie heeft contact opgenomen met Faalkaart en toegezegd om op korte termijn verandering door te voeren om de score te verbeteren. Faalkaart draait dagelijks nieuwe scans op alle organsaties en domeinen, de resultaten van deze veranderingen zullen dus binnenkort zichtbaar zijn.
</div>
<br/>
{% verbatim %}
<div v-for="url in urls" class="perurl" v-bind:style="'background: linear-gradient(' + colorizebg(url.points) + ', white);'">
<div class="screenshotlist">
......
......@@ -13,7 +13,7 @@ from django.utils.translation import ugettext as _
from django.views.decorators.cache import cache_page
from failmap_admin.map.models import OrganizationRating, UrlRating
from failmap_admin.organizations.models import Organization, Url
from failmap_admin.organizations.models import Organization, Promise, Url
from .. import __version__
......@@ -92,6 +92,7 @@ def organization_report(request, organization_id, weeks_back=0):
'pk',
'twitter_handle').latest('organizationrating__when')
# latest replaced: order_by('-organizationrating__when')[:1].get()
promises = bool(Promise.objects.filter(organization_id=organization_id, expires_on__gt=datetime.now()).count())
report_json = """
{
......@@ -100,7 +101,8 @@ def organization_report(request, organization_id, weeks_back=0):
"twitter_handle": "%s",
"rating": %s,
"when": "%s",
"calculation": %s
"calculation": %s,
"promises": %s
}
"""
report_json = report_json % (
......@@ -110,6 +112,7 @@ def organization_report(request, organization_id, weeks_back=0):
r['organizationrating__rating'],
r['organizationrating__when'].isoformat(),
r['organizationrating__calculation'],
promises,
)
# print(report_json)
except Organization.DoesNotExist:
......
......@@ -17,7 +17,7 @@ from failmap_admin.scanners.scanner_security_headers import scan_urls as securit
from failmap_admin.scanners.scanner_tls_qualys import ScannerTlsQualys
from ..app.models import Job
from .models import Coordinate, Organization, OrganizationType, Url
from .models import Coordinate, Organization, OrganizationType, Promise, Url
logger = logging.getLogger(__name__)
......@@ -229,7 +229,15 @@ class CoordinateAdmin(admin.ModelAdmin):
fields = ('organization', 'geojsontype', 'area')
class PromiseAdmin(admin.ModelAdmin):
list_display = ('organization', 'created_on', 'expires_on')
search_fields = ('organization',)
list_filter = ('organization',)
fields = ('organization', 'created_on', 'expires_on', 'notes')
admin.site.register(Organization, OrganizationAdmin)
admin.site.register(Url, UrlAdmin)
admin.site.register(Coordinate, CoordinateAdmin)
admin.site.register(OrganizationType, OrganizationTypeAdmin)
admin.site.register(Promise, PromiseAdmin)
# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2017-11-11 09:52
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('organizations', '0018_auto_20171017_1317'),
]
operations = [
migrations.CreateModel(
name='Promise',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('notes', models.TextField(help_text='Context information about the promise (eg: ticket reference).')),
('created_on', models.DateTimeField(auto_now_add=True, null=True)),
('expires_on', models.DateTimeField(blank=True, null=True)),
('organization', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='organizations.Organization')),
],
),
]
# coding=UTF-8
# from __future__ import unicode_literals
from datetime import datetime
from django.core.exceptions import ValidationError
from django.db import models
from django_countries.fields import CountryField
......@@ -161,3 +163,19 @@ class Url(models.Model):
# so they are not used anymore.
# class Port(models.Model):
# url = models.ForeignKey(Url, on_delete=models.PROTECT)
class Promise(models.Model):
"""Allow recording of organisation promises for improvement."""
organization = models.ForeignKey(Organization, on_delete=models.PROTECT)
notes = models.TextField(help_text="Context information about the promise (eg: ticket reference).")
created_on = models.DateTimeField(default=datetime.now, blank=True, null=True)
expires_on = models.DateTimeField(
blank=True,
null=True,
help_text="When in the future this promise is expected to be fulfilled.")
def __str__(self):
return '%s - %s' % (self.organization.name, self.created_on)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment