# 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
        max_length=50, blank=True, null=True, help_text="xml article-type."
    )
    ejp_type = models.CharField(
        max_length=3,
        blank=True,
        null=True,
        help_text="article as exported from EJP submission system",
    )  # RA, SR, etc

    def ejp_rev_type(self):
        return EJP_TYPE_IDX.get(self.ejp_type, "unknown")

    datetime_record_created = models.DateTimeField(
        auto_now_add=True, help_text="Date this article was created"
    )
    datetime_record_updated = models.DateTimeField(
        auto_now=True, help_text="Date this article was updated"
    )

    def earliest_poa(self, defer=True):
        try:
            if defer:
                return (
                    self.articleversion_set.defer(
                        "article_json_v1", "article_json_v1_snippet"
                    )
                    .filter(status=POA)
                    .earliest("version")
                )
            return self.articleversion_set.filter(status=POA).earliest("version")

# 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

        max_length=50, blank=True, null=True, help_text="xml article-type."
    )
    ejp_type = models.CharField(
        max_length=3,
        blank=True,
        null=True,
        help_text="article as exported from EJP submission system",
    )  # RA, SR, etc

    def ejp_rev_type(self):
        return EJP_TYPE_IDX.get(self.ejp_type, "unknown")

    datetime_record_created = models.DateTimeField(
        auto_now_add=True, help_text="Date this article was created"
    )
    datetime_record_updated = models.DateTimeField(
        auto_now=True, help_text="Date this article was updated"
    )

    def earliest_poa(self, defer=True):
        try:
            if defer:
                return (
                    self.articleversion_set.defer(
                        "article_json_v1", "article_json_v1_snippet"
                    )
                    .filter(status=POA)
                    .earliest("version")
                )
            return self.articleversion_set.filter(status=POA).earliest("version")

        except models.ObjectDoesNotExist: