# Path: src/publisher/utils.py
# def msid2doi(msid):
#     assert isint(msid), "given msid must be an integer: %r" % msid
#     return "10.7554/eLife.%s" % pad_msid(msid)
# 
# def mk_dxdoi_link(doi):
#     return "https://dx.doi.org/%s" % doi
# 
# def json_dumps(obj, **kwargs):
#     "drop-in for json.dumps that handles datetime objects."
# 
#     def _handler(obj):
#         # datetime objects: 2015-03-17T00:00:00+00:00
#         # date objects: 2015-03-17
#         obj_t = type(obj)
#         if obj_t == date:
#             return ymd(obj)
#         if obj_t == datetime:
#             return ymdhms(obj)
#         raise TypeError(
#             "Object of type %s with value of %s is not JSON serializable"
#             % (type(obj), repr(obj))
#         )
# 
#     return json.dumps(obj, default=_handler, **kwargs)
# 
# def ordered_json_loads(data):
#     "same as json_loads, just ensures order is preserved when loading maps"
#     return json_loads(data, object_pairs_hook=OrderedDict)


from slugify import slugify
from django.db import models
from functools import partial
from annoying.fields import JSONField
from .utils import msid2doi, mk_dxdoi_link, json_dumps, ordered_json_loads
from django.core.exceptions import ObjectDoesNotExist
from django.conf import settings
    def _doi(self):
        return msid2doi(self.manuscript_id)

    # these come from EJP

    # data exists but isn't being considered. for reporting reasons, 'submission date' is date of initial quality check
    # NOTE 2016-09-06: disabled. expectation of data in this field was becoming annoying.
    # datetime_submitted = models.DateTimeField(blank=True, null=True, help_text="Date author submitted article")

    # this field would be the most recent 'full decision accept' event
    # datetime_accepted = models.DateTimeField(blank=True, null=True, help_text="Date article accepted for publication")

    date_initial_qc = models.DateField(blank=True, null=True)
    date_initial_decision = models.DateField(blank=True, null=True)
    initial_decision = models.CharField(
        max_length=25, blank=True, null=True, choices=decision_codes()
    )

    date_full_qc = models.DateField(blank=True, null=True)
    date_full_decision = models.DateField(blank=True, null=True)
    decision = models.CharField(
        max_length=25, blank=True, null=True, choices=decision_codes()
    )

    date_rev1_qc = models.DateField(blank=True, null=True)
    date_rev1_decision = models.DateField(blank=True, null=True)
    rev1_decision = models.CharField(
        max_length=25, blank=True, null=True, choices=decision_codes()
    )


# Path: src/publisher/utils.py
# def msid2doi(msid):
#     assert isint(msid), "given msid must be an integer: %r" % msid
#     return "10.7554/eLife.%s" % pad_msid(msid)
# 
# def mk_dxdoi_link(doi):
#     return "https://dx.doi.org/%s" % doi
# 
# def json_dumps(obj, **kwargs):
#     "drop-in for json.dumps that handles datetime objects."
# 
#     def _handler(obj):
#         # datetime objects: 2015-03-17T00:00:00+00:00
#         # date objects: 2015-03-17
#         obj_t = type(obj)
#         if obj_t == date:
#             return ymd(obj)
#         if obj_t == datetime:
#             return ymdhms(obj)
#         raise TypeError(
#             "Object of type %s with value of %s is not JSON serializable"
#             % (type(obj), repr(obj))
#         )
# 
#     return json.dumps(obj, default=_handler, **kwargs)
# 
# def ordered_json_loads(data):
#     "same as json_loads, just ensures order is preserved when loading maps"
#     return json_loads(data, object_pairs_hook=OrderedDict)


# Path: src/publisher/models.py
from slugify import slugify
from django.db import models
from functools import partial
from annoying.fields import JSONField
from .utils import msid2doi, mk_dxdoi_link, json_dumps, ordered_json_loads
from django.core.exceptions import ObjectDoesNotExist
from django.conf import settings

    def _doi(self):
        return msid2doi(self.manuscript_id)

    # these come from EJP

    # data exists but isn't being considered. for reporting reasons, 'submission date' is date of initial quality check
    # NOTE 2016-09-06: disabled. expectation of data in this field was becoming annoying.
    # datetime_submitted = models.DateTimeField(blank=True, null=True, help_text="Date author submitted article")

    # this field would be the most recent 'full decision accept' event
    # datetime_accepted = models.DateTimeField(blank=True, null=True, help_text="Date article accepted for publication")

    date_initial_qc = models.DateField(blank=True, null=True)
    date_initial_decision = models.DateField(blank=True, null=True)
    initial_decision = models.CharField(
        max_length=25, blank=True, null=True, choices=decision_codes()
    )

    date_full_qc = models.DateField(blank=True, null=True)
    date_full_decision = models.DateField(blank=True, null=True)
    decision = models.CharField(
        max_length=25, blank=True, null=True, choices=decision_codes()
    )

    date_rev1_qc = models.DateField(blank=True, null=True)
    date_rev1_decision = models.DateField(blank=True, null=True)
    rev1_decision = models.CharField(
        max_length=25, blank=True, null=True, choices=decision_codes()
    )


    date_rev2_qc = models.DateField(blank=True, null=True)