# 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

EJP_TYPE_IDX = dict(ejp_type_choices())
EJP_TYPE_REV_SLUG_IDX = {
    slugify(str(val), stopwords=["and"]): key for key, val in ejp_type_choices()
}


EDITORIAL, INSIGHT = "editorial", "insight"

# TODO: this mapping is unused and can be removed
def xml_type_choices():
    return [
        ("research-article", "Research article"),
        ("short-report", "Short report"),
        ("research-advance", "Research advance"),
        ("registered-report", "Registered report"),
        ("tools-resources", "Tools and resources"),
        ("replication-study", "Replication Study"),
        # not present in ejp
        ("correction", "Correction"),
        ("feature", "Feature article"),
        (INSIGHT, "Insight"),
        (EDITORIAL, "Editorial"),
        (None, "not set"),
    ]


AF = "AF"



# 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


EJP_TYPE_IDX = dict(ejp_type_choices())
EJP_TYPE_REV_SLUG_IDX = {
    slugify(str(val), stopwords=["and"]): key for key, val in ejp_type_choices()
}


EDITORIAL, INSIGHT = "editorial", "insight"

# TODO: this mapping is unused and can be removed
def xml_type_choices():
    return [
        ("research-article", "Research article"),
        ("short-report", "Short report"),
        ("research-advance", "Research advance"),
        ("registered-report", "Registered report"),
        ("tools-resources", "Tools and resources"),
        ("replication-study", "Replication Study"),
        # not present in ejp
        ("correction", "Correction"),
        ("feature", "Feature article"),
        (INSIGHT, "Insight"),
        (EDITORIAL, "Editorial"),
        (None, "not set"),
    ]


AF = "AF"



def decision_codes():