Skip to content

Commit

Permalink
Merge branch 'release/2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
luissian committed Apr 20, 2022
2 parents 6997dd4 + 7281cf0 commit a9ed24c
Show file tree
Hide file tree
Showing 25 changed files with 625 additions and 110 deletions.
1 change: 1 addition & 0 deletions conf/apache2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
WSGIDaemonProcess iSkyLIMS python-home=/opt/iSkyLIMS/virtualenv python-path=/opt/iSkyLIMS
WSGIProcessGroup iSkyLIMS
WSGIScriptAlias / /opt/iSkyLIMS/iSkyLIMS/wsgi.py
WSGIPassAuthorization On

</VirtualHost>
1 change: 1 addition & 0 deletions conf/pythonPackagesRequired.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ paramiko
pysmb
django_extensions
djangorestframework
drf-yasg
xlrd
pandas
openpyxl
17 changes: 17 additions & 0 deletions conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'django.contrib.staticfiles',
'django_extensions',
'rest_framework',
'drf_yasg',
'django_cleanup', # should go after your apps
]

Expand Down Expand Up @@ -121,7 +122,23 @@
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': {
'basic': {
'type': 'basic'
}
}
}

""" For using token in the authorization request
'api_key': {
'type': 'apiKey',
'in': 'header',
'name': 'Authorization'
}
"""
# 'PERSIST_AUTH': True

# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
Expand Down
13 changes: 13 additions & 0 deletions conf/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
from django.urls import include, path
from django.contrib import admin
from django.contrib.auth.views import LoginView
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

schema_view = get_schema_view(openapi.Info(
title="iSkyLIMS API",
default_version='v0.0.1',
description="iSkyLIMS API",
),
public=True,
)


urlpatterns = [
path('',include('iSkyLIMS_core.urls')),
Expand All @@ -16,4 +27,6 @@

# REST FRAMEWORK URLS
path('drylab/api/', include('iSkyLIMS_drylab.api.urls')),
path('wetlab/api/', include('iSkyLIMS_wetlab.api.urls')),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0))
]
22 changes: 16 additions & 6 deletions iSkyLIMS_core/core_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@

################# SAMPLE SETTINGS ##############################
### Headings used when recording information
HEADING_FOR_RECORD_SAMPLES = [ 'Patient Code ID', 'Sample Name', 'Lab requested', 'Type of Sample', 'Species', 'Project/Service', 'Date sample reception', 'Sample Storage Location','Only recorded']
HEADING_FOR_RECORD_SAMPLES = ['Patient Code ID', 'Sample Name', 'Lab requested', 'Type of Sample', 'Species', 'Project/Service', 'Date sample reception', 'Collection Sample Date', 'Sample Storage Location', 'Only recorded']

HEADING_FOR_OPTIONAL_FIELD_SAMPLES = [ 'Patient Code ID', 'Lab requested', 'Species', 'Date sample reception', 'Sample Storage Location']
HEADING_FOR_OPTIONAL_FIELD_SAMPLES = [ 'Patient Code ID', 'Lab requested', 'Species', 'Date sample reception', 'Collection Sample Date', 'Sample Storage Location']

HEADING_FOR_DISPLAY_RECORDED_SAMPLES = ['Unique Sample ID', 'Sample CodeID', 'Sample Name', 'Date for entry in Lab', 'Type of Sample']

HEADING_FOR_COMPLETION_SAMPLES_PRE_DEFINED = ['Date sample extraction' , 'Sample CodeID', 'Sample name']

MAPPING_SAMPLE_FORM_TO_DDBB = [('Patient Code ID','p_code_id'), ('Sample Name', 'sampleName'), ('Lab requested', 'labRequest'),
('Type of Sample','sampleType'), ('Species', 'species'),('Project/Service', 'project_service'),('Date sample extraction', 'sampleEntryDate'),
('Sample Storage Location', 'sampleLocation'), ('Only recorded','onlyRecorded')]
MAPPING_SAMPLE_FORM_TO_DDBB = [
('Patient Code ID', 'p_code_id'), ('Sample Name', 'sampleName'),
('Lab requested', 'labRequest'), ('Type of Sample', 'sampleType'),
('Species', 'species'), ('Project/Service', 'project_service'),
('Date sample extraction', 'sampleEntryDate'),
('Collection Sample Date', 'collectionSampleDate'),
('Sample Storage Location', 'sampleLocation'),
('Only recorded', 'onlyRecorded')
]

HEADING_FOR_MOLECULE_PROTOCOL_DEFINITION = ['Sample ID','Sample Type', 'Molecule type', 'Type of Extraction', 'Extraction date', 'Protocol to be used']
HEADING_FOR_MOLECULE_ADDING_PARAMETERS = ['Molecule Code ID', 'Lot Commercial Kit']
Expand All @@ -37,7 +43,11 @@
'Used Protocol', 'UserID']

### Heading for display information on sample definition
HEADING_FOR_SAMPLE_DEFINITION = ['Sample Name', 'Sample CodeID','Sample State', 'Recorded Date', 'Sample Type', 'Species', 'Number of reused', 'User']
HEADING_FOR_SAMPLE_DEFINITION = [
'Sample Name', 'Sample CodeID', 'Sample State', 'Recorded Date',
'Collection Sample Date', 'Date sample reception', 'Sample Type', 'Species',
'Number of reused', 'User'
]
### Heading for display information on molecule definition
HEADING_FOR_MOLECULE_DEFINITION = ['Molecule CodeID', 'Molecule State','Extraction Date', 'Extraction Type', 'Molecule Type', 'Used for', 'Used Protocol', 'Number of reused']

Expand Down
60 changes: 41 additions & 19 deletions iSkyLIMS_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def __str__ (self):
def get_sample_state (self):
return '%s' %(self.sampleStateName)

def get_id(self):
return "%s" %(self.pk)


class StatesForMolecule (models.Model):
moleculeStateName = models.CharField(max_length=50)
Expand Down Expand Up @@ -667,7 +670,7 @@ class SampleProjectsFields (models.Model):
on_delete= models.CASCADE, null = True, blank = True)
#sampleProjectsOptionValues = models.ManyToManyField(SamplesProjectsOptionValues, blank = True)

sampleProjectFieldName = models.CharField(max_length=50)
sampleProjectFieldName = models.CharField(max_length=80)
sampleProjectFieldDescription = models.CharField(max_length= 400, null=True, blank=True)
sampleProjectFieldOrder = models.IntegerField()
sampleProjectFieldUsed = models.BooleanField()
Expand Down Expand Up @@ -768,30 +771,38 @@ def get_option_value(self):
objects = SamplesProjectsOptionValuesManager()
'''

class SamplesManager (models.Manager):

def create_sample (self, sample_data):
## Set to null in case that there is not samples_origin defined
class SamplesManager (models.Manager):

def create_sample(self, sample_data):
if sample_data['labRequest'] != '':
sample_data['labRequest'] = LabRequest.objects.get(labNameCoding__exact = sample_data['labRequest'])
sample_data['labRequest'] = LabRequest.objects.get(labNameCoding__exact=sample_data['labRequest'])
else:
sample_data['labRequest'] = None
if sample_data['species'] != '':
sample_data['species'] = Species.objects.get(speciesName__exact = sample_data['species'])
sample_data['species'] = Species.objects.get(speciesName__exact=sample_data['species'])
else:
sample_data['species'] = None
new_sample = self.create(sampleState = StatesForSample.objects.get(sampleStateName__exact = sample_data['sampleState']),
patientCore = sample_data['patient'],
labRequest = sample_data['labRequest'], sampleProject = sample_data['sampleProject'],
sampleType = SampleType.objects.get(sampleType__exact = sample_data['sampleType'], apps_name__exact = sample_data['app_name']) ,
sampleUser = User.objects.get(username__exact = sample_data['user']),
sampleCodeID = sample_data['sample_id'] , sampleName = sample_data['sampleName'],
uniqueSampleID = sample_data['new_unique_value'],
species = sample_data['species'],
sampleLocation = sample_data['sampleLocation'], onlyRecorded = sample_data['onlyRecorded'],
#sampleEntryDate = datetime.datetime.strptime(sample_data['Date for entry in Lab'],'%Y-%m-%d %H:%M:%S'))
sampleEntryDate = datetime.datetime.strptime(sample_data['sampleEntryDate'],'%Y-%m-%d %H:%M:%S'))
if 'completedDate' in sample_data:
completedDate = datetime.datetime.strptime(sample_data['completedDate'], '%Y-%m-%d %H:%M:%S')
else:
completedDate = None
import pdb; pdb.set_trace()
new_sample = self.create(
sampleState=StatesForSample.objects.get(sampleStateName__exact=sample_data['sampleState']),
patientCore=sample_data['patient'],
labRequest=sample_data['labRequest'],
sampleProject=sample_data['sampleProject'],
sampleType=SampleType.objects.get(sampleType__exact=sample_data['sampleType'], apps_name__exact=sample_data['app_name']),
sampleUser=User.objects.get(username__exact=sample_data['user']),
sampleCodeID=sample_data['sample_id'], sampleName=sample_data['sampleName'],
uniqueSampleID=sample_data['new_unique_value'],
species=sample_data['species'],
sampleLocation=sample_data['sampleLocation'], onlyRecorded=sample_data['onlyRecorded'],
sampleEntryDate=datetime.datetime.strptime(sample_data['sampleEntryDate'], '%Y-%m-%d %H:%M:%S'),
collectionSampleDate=datetime.datetime.strptime(sample_data['sampleEntryDate'], '%Y-%m-%d %H:%M:%S'),
completedDate=completedDate
)

return new_sample

Expand Down Expand Up @@ -826,6 +837,7 @@ class Samples (models.Model):
sampleName = models.CharField(max_length=255, null = True)
sampleLocation = models.CharField(max_length=255, null = True, blank = True)
sampleEntryDate = models.DateTimeField(auto_now_add = False, null =True)
collectionSampleDate = models.DateTimeField(auto_now_add = False, null =True)
uniqueSampleID = models.CharField(max_length=8, null = True)
sampleCodeID = models.CharField(max_length=60, null = True)
numberOfReused = models.IntegerField(default=0)
Expand Down Expand Up @@ -869,12 +881,22 @@ def get_info_for_searching (self):
sample_info.append('Not defined')
return sample_info

def get_info_for_display (self):
def get_info_for_display(self):
if self.collectionSampleDate:
collectionSampleDate = self.collectionSampleDate.strftime("%d , %B , %Y")
else:
collectionSampleDate = ""
if self.sampleEntryDate:
sampleEntryDate = self.sampleEntryDate.strftime("%d , %B , %Y")
else:
sampleEntryDate = ""
sample_info = []
sample_info.append(self.sampleName)
sample_info.append(self.sampleCodeID)
sample_info.append(self.sampleState.get_sample_state())
sample_info.append(self.generated_at.strftime("%d , %B , %Y"))
sample_info.append(collectionSampleDate)
sample_info.append(sampleEntryDate)
sample_info.append(self.sampleType.get_name())
sample_info.append(self.species.get_name())
sample_info.append(self.numberOfReused)
Expand Down Expand Up @@ -1008,7 +1030,7 @@ class MoleculeUsedFor (models.Model):
apps_name = models.CharField(max_length = 50)
massiveUse = models.BooleanField(default= False)

def __str__ (self):
def __str__(self):
return '%s' %(self.usedFor)

def get_molecule_use_name (self):
Expand Down
2 changes: 1 addition & 1 deletion iSkyLIMS_core/templates/iSkyLIMS_core/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h4>Powered by :</h4>
</div>
<div class="row">
<div class="col-md-2 col-md-offset-5">
<p>Version 2.2.2</p>
<p>Version 2.3.0</p>
</div>
</div>
<!--// end row -->
Expand Down
Loading

0 comments on commit a9ed24c

Please # to comment.