Created
January 11, 2019 08:39
-
-
Save thclark/59a1dbdede2bc32353d2a7283840655c to your computer and use it in GitHub Desktop.
Django view for providing DataTables
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
from app.models import Manifest, ManifestFileRecord | |
from django_datatables_view.base_datatable_view import BaseDatatableView | |
logger = logging.getLogger(__name__) | |
class ManifestDatatableView(BaseDatatableView): | |
model = Manifest | |
columns = ['id', 'name', 'created', 'updated', 'tags', 'automan_params'] | |
order_columns = ['id', 'name', 'created', 'updated', 'tags'] | |
def get_initial_queryset(self): | |
return self.model.objects.all() | |
class ManifestFileRecordDatatableView(BaseDatatableView): | |
model = ManifestFileRecord | |
columns = ['name', 'cluster', 'sequence', 'tags', 'posix_timestamp'] | |
order_columns = ['name', 'cluster', 'sequence', 'tags', 'posix_timestamp'] | |
def get_initial_queryset(self): | |
""" | |
:return: queryset containing ManifestFileRecords. If a manifest_id parameter is supplied, restrict to only ManifestFileRecords in that manifest | |
""" | |
if 'manifest_id' in self.kwargs.keys(): | |
return self.model.objects.filter(manifest_id=self.kwargs['manifest_id']).all() | |
raise Exception('Stopped here to avoid leakage of all file records to an aggressor who does not have a uuid') | |
# return self.model.objects.all() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment