django provides django.utils.timezone.now to return a timezone aware timestamp if...
[htsworkflow.git] / htsworkflow / frontend / experiments / experiments.py
index 1ccba526adb75272273985c0095db2361e09d40f..9493765dcb02cf31528c295be5dd5bd5389165cf 100644 (file)
@@ -9,11 +9,12 @@ import os
 import re
 
 from django.contrib.auth.decorators import login_required
-from django.contrib.csrf.middleware import csrf_exempt
+from django.views.decorators.csrf import csrf_exempt
 from django.core.exceptions import ObjectDoesNotExist
 from django.core.mail import send_mail, mail_admins
 from django.http import HttpResponse, Http404
 from django.conf import settings
+from django.utils import timezone
 
 from htsworkflow.frontend.auth import require_api_key
 from htsworkflow.frontend.experiments.models import \
@@ -179,7 +180,7 @@ def updStatus(request):
       rec.run_status = UpdatedStatus
 
       #if there's a message update that too
-      mytimestamp = datetime.now().__str__()
+      mytimestamp = timezone.now().__str__()
       mytimestamp = re.sub(pattern=":[^:]*$",repl="",string=mytimestamp)
       if request.REQUEST.has_key('msg'):
         rec.run_note += ", "+request.REQUEST['msg']+" ("+mytimestamp+")"
@@ -325,7 +326,7 @@ def estimateFlowcellTimeRemaining(flowcell):
     estimate_mid = estimateFlowcellDuration(flowcell)
 
     # offset for how long we've been running
-    running_time = datetime.now() - flowcell.run_date
+    running_time = timezone.now() - flowcell.run_date
     estimate_mid -= running_time
 
     return estimate_mid