Skip to content
28 changes: 10 additions & 18 deletions physionet-django/console/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import re
import pdb
import logging
import os
import csv
Expand All @@ -8,8 +6,6 @@
from statistics import median, StatisticsError
from collections import OrderedDict

from django.core.exceptions import ObjectDoesNotExist
from django.core.validators import validate_email
from django.contrib import messages
from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.contenttypes.forms import generic_inlineformset_factory
Expand All @@ -18,12 +14,9 @@
from django.shortcuts import redirect, render, get_object_or_404
from django.urls import reverse
from django.utils import timezone
from django.db import DatabaseError, transaction
from django.db.models import (Q, CharField, Value, IntegerField, F, functions,
DurationField)
from django.db.models import Q, Value, IntegerField, F, DurationField
from django.db.models.functions import Cast
from background_task import background
from django.contrib.sites.models import Site
from dal import autocomplete

from notification.models import News
Expand All @@ -37,8 +30,7 @@
exists_project_slug, GCP, DUASignature, DataAccess)
from project.utility import readable_size
from project.validators import MAX_PROJECT_SLUG_LENGTH
from project.views import (get_file_forms, get_project_file_info,
process_files_post)
from project.views import get_file_forms, process_files_post
from user.models import (User, CredentialApplication, LegacyCredential,
AssociatedEmail, CredentialReview)
from console import forms, utility
Expand Down Expand Up @@ -414,7 +406,7 @@ def copyedit_submission(request, project_slug, *args, **kwargs):
authors, author_emails, storage_info, edit_logs, copyedit_logs, latest_version = project.info_card()

(display_files, display_dirs, dir_breadcrumbs, _,
file_error) = get_project_file_info(project=project, subdir=subdir)
file_error) = project.get_file_info(subdir=subdir)

(upload_files_form, create_folder_form, rename_item_form,
move_items_form, delete_items_form) = get_file_forms(
Expand Down Expand Up @@ -826,7 +818,7 @@ def manage_published_project(request, project_slug, version):
'storage_info': storage_info, 'edit_logs': edit_logs,
'copyedit_logs': copyedit_logs, 'latest_version': latest_version,
'published': True, 'topic_form': topic_form,
'deprecate_form': deprecate_form, 'has_credentials': has_credentials,
'deprecate_form': deprecate_form, 'has_credentials': has_credentials,
'data_access_form': data_access_form, 'data_access': data_access,
'rw_tasks': rw_tasks, 'ro_tasks': ro_tasks,
'anonymous_url': anonymous_url, 'passphrase': passphrase,
Expand Down Expand Up @@ -952,7 +944,7 @@ def users_search(request, group):
Search user list.

Args:
group (str): group of users to filter search. Either 'all' for all users or
group (str): group of users to filter search. Either 'all' for all users or
'inactive' to filter to inactive users only.
"""

Expand Down Expand Up @@ -1121,8 +1113,8 @@ def complete_list_credentialed_people(request):
item.email, item.country, datetime.strptime(item.mimic_approval_date, '%m/%d/%Y'),
None, item.info])
for item in new_cred_user:
credentialed_people.append([item.first_names, item.last_name,
item.user.email, item.country, item.decision_datetime.replace(tzinfo=None),
credentialed_people.append([item.first_names, item.last_name,
item.user.email, item.country, item.decision_datetime.replace(tzinfo=None),
item.decision_datetime.replace(tzinfo=None), item.research_summary])

credentialed_people = sorted(credentialed_people, key = lambda x: x[4])
Expand Down Expand Up @@ -1582,7 +1574,7 @@ def news_console(request):
"""
news_items = News.objects.all().order_by('-publish_datetime')
news_items = paginate(request, news_items, 50)
return render(request, 'console/news_console.html',
return render(request, 'console/news_console.html',
{'news_items': news_items, 'news_nav': True})


Expand Down Expand Up @@ -1854,8 +1846,8 @@ def download_credentialed_users(request):
# Create the HttpResponse object with the appropriate CSV header.
project_access = DUASignature.objects.filter(project__access_policy = 2)
added = []
dua_info_csv = [['First name', 'Last name', 'E-mail', 'Institution', 'Country',
'MIMIC approval date', 'eICU approval date',
dua_info_csv = [['First name', 'Last name', 'E-mail', 'Institution', 'Country',
'MIMIC approval date', 'eICU approval date',
'General research area for which the data will be used']]
for person in project_access:
application = person.user.credential_applications.last()
Expand Down
33 changes: 33 additions & 0 deletions physionet-django/physionet/abcmodel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from abc import ABCMeta

from django.db import models


class AbstractModelMeta(ABCMeta, type(models.Model)):
"""
Like Python ABCMeta, except compatible with Django models.
Used to enable the use of abstract methods in model subclasses.

Ref: https://gist.github.com/gavinwahl/7778717

See below for how to use.
"""
pass


"""
class ABCModel(models.Model, metaclass=AbstractModelMeta):
class Meta:
abstract = True

@abstractmethod
def methodtobeimplemented(self):
pass


class ActualModel(ABCModel):
def methodtobeimplemented(self):
somelogic()

"""

2 changes: 1 addition & 1 deletion physionet-django/project/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ActiveProjectFilesForm(forms.Form):
"""
# The working subdirectory relative to the project root
subdir = forms.CharField(widget=forms.HiddenInput(), required=False,
validators=[validators.validate_subdir])
validators=[validators.validate_relative_path])

def __init__(self, project, *args, **kwargs):
super(ActiveProjectFilesForm, self).__init__(*args, **kwargs)
Expand Down
Loading