Skip to content
Snippets Groups Projects
Commit eedf9263 authored by Carlos Vega's avatar Carlos Vega
Browse files

added property to get provenances

parent 1fe34491
No related branches found
No related tags found
1 merge request!233Feature/provenance
......@@ -3,19 +3,22 @@ import logging
import re
from django.db import models
from web.models import VoucherType, Appointment, Location, Visit
from web.models import VoucherType, Appointment, Location, Visit, Provenance
from web.models.constants import BOOL_CHOICES, SUBJECT_TYPE_CHOICES, FILE_STORAGE
from django.db.models.signals import post_save
from django.dispatch import receiver
logger = logging.getLogger(__name__)
class StudySubject(models.Model):
class Meta:
app_label = 'web'
@property
def provenances(self):
return Provenance.objects.filter(modified_table=StudySubject._meta.db_table).filter(modified_table_id=self.id).order_by('-modification_date')
def finish_all_visits(self):
visits = Visit.objects.filter(subject=self, is_finished=False)
for visit in visits:
......
......@@ -14,6 +14,10 @@ class Subject(models.Model):
class Meta:
app_label = 'web'
@property
def provenances(self):
return Provenance.objects.filter(modified_table=Subject._meta.db_table).filter(modified_table_id=self.id).order_by('-modification_date')
sex = models.CharField(max_length=1,
choices=SEX_CHOICES,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment