Skip to content
Snippets Groups Projects
Commit d8067ffc authored by James Graham's avatar James Graham
Browse files

Add support for encrypted datasets - just mark them as encrypted

parent b78153ed
Branches
Tags
1 merge request!60Merge dev pre-hackday
from django.contrib import admin
from . import models
from . import forms, models
@admin.register(models.DataSource)
class DataSourceAdmin(admin.ModelAdmin):
readonly_fields = ['owner']
form = forms.DataSourceForm
def has_change_permission(self, request, obj=None) -> bool:
"""
......
......@@ -3,6 +3,27 @@ from django import forms
from . import models
class DataSourceForm(forms.ModelForm):
"""
Form class for creating / updating DataSource.
"""
class Meta:
model = models.DataSource
exclude = ['owner']
def clean_encrypted_docs_url(self):
"""
Make sure that 'is_encrypted' and 'encrypted_docs_url' are always present as a pair.
"""
if self.cleaned_data['encrypted_docs_url'] and not self.cleaned_data['is_encrypted']:
raise forms.ValidationError('You may not provide an encryption documentation URL if the data is not encrypted')
if self.cleaned_data['is_encrypted'] and not self.cleaned_data['encrypted_docs_url']:
raise forms.ValidationError('You must provide an encryption documentation URL is the data is encrypted')
return self.cleaned_data['encrypted_docs_url']
class PermissionRequestForm(forms.ModelForm):
class Meta:
model = models.UserPermissionLink
......
# Generated by Django 2.0.8 on 2018-11-12 08:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('datasources', '0012_add_request_reason'),
]
operations = [
migrations.AddField(
model_name='datasource',
name='is_encrypted',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='datasource',
name='encrypted_docs_url',
field=models.URLField(blank=True, verbose_name='Documentation URL for managing encrypted data'),
),
]
......@@ -100,6 +100,14 @@ class DataSource(BaseAppDataModel):
api_key = models.CharField(max_length=MAX_LENGTH_API_KEY,
blank=True, null=False)
#: Contains encrypted data?
is_encrypted = models.BooleanField(default=False,
blank=False, null=False)
#: Where to find information about how to use this encrypted data
encrypted_docs_url = models.URLField('Documentation URL for managing encrypted data',
blank=True, null=False)
#: Which authentication method to use - defined in :class:`datasources.connectors.base.AuthMethod` enum
auth_method = models.IntegerField(choices=AuthMethod.choices(),
default=AuthMethod.UNKNOWN.value,
......
......@@ -7,7 +7,7 @@
{% endblock %}
{% block pre_content %}
<header class="masthead text-white text-left" style="background-image: url('https://via.placeholder.com/350x150')">
<header class="container-fluid masthead text-white text-left" style="background-image: url('https://via.placeholder.com/350x150')">
<div class="overlay"></div>
<div class="row">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment