Skip to content

Commit

Permalink
Fix problem with need update when tex is generated and not the pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Feb 9, 2020
1 parent d821c85 commit b0cf954
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion survey/exporter/tex/survey2tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import logging
import os
from datetime import datetime
from pathlib import Path
from pydoc import locate

from django.conf import settings
import pytz
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _

from survey.exporter.survey2x import Survey2X
Expand Down Expand Up @@ -108,6 +111,19 @@ def generate(self, path, output=None):
os.system("mv {}.pdf {}".format(file_name[:-3], output))
os.chdir(previous_directory)

@property
def file_modification_time(self):
""" Return the modification time of the pdf. """
pdf_path = Path(self._get_x_dir(), "{}.pdf".format(slugify(self.survey.name)))
if not pdf_path.exists():
earliest_working_timestamp_for_windows = 86400
mtime = earliest_working_timestamp_for_windows
else:
mtime = os.path.getmtime(pdf_path)
mtime = datetime.utcfromtimestamp(mtime)
mtime = mtime.replace(tzinfo=pytz.timezone("UTC"))
return mtime

def survey_to_x(self, questions=None):
if questions is None:
questions = self.survey.questions.all()
Expand Down

0 comments on commit b0cf954

Please sign in to comment.