Skip to content

Commit

Permalink
Merge pull request #906 from laws-africa/no-arrow
Browse files Browse the repository at this point in the history
Replace arrow with iso8601
  • Loading branch information
longhotsummer committed Jan 13, 2020
2 parents a3c58ca + 84cc5e7 commit a19c138
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions indigo_api/migrations/0021_document_expression_date.py
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
import arrow
from django.db import models, migrations
from indigo_api.models import Document
from django.utils.timezone import now


def forwards(apps, schema_editor):
for doc in Document.objects.select_related(None).only('document_xml', 'expression_date').all():
doc.expression_date = doc.publication_date or arrow.now().date()
doc.expression_date = doc.publication_date or now().date()
doc.save()


Expand Down
4 changes: 2 additions & 2 deletions indigo_api/migrations/0042_add_repeal_works.py
Expand Up @@ -3,7 +3,7 @@
from django.db import migrations

from cobalt.act import datestring
import arrow
from iso8601 import parse_date


def create_repeals(apps, schema_editor):
Expand All @@ -18,7 +18,7 @@ def create_repeals(apps, schema_editor):

for doc in documents:
if doc.repeal_event:
date = arrow.get(doc.repeal_event['date']).date()
date = parse_date(doc.repeal_event['date']).date()

work = works.get(doc.repeal_event['repealing_uri'])
if not work:
Expand Down
4 changes: 2 additions & 2 deletions indigo_api/migrations/0046_works_for_amendments.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-04-16 14:56
from django.db import migrations
import arrow
from iso8601 import parse_date

from cobalt.act import FrbrUri

Expand All @@ -19,7 +19,7 @@ def create_amendments(apps, schema_editor):
for doc in documents:
for amendment in (doc.amendment_events or []):
work = works.get(amendment['amending_uri'])
date = arrow.get(amendment['date']).date()
date = parse_date(amendment['date']).date()

if not work:
# validate frbr_uri
Expand Down
12 changes: 6 additions & 6 deletions indigo_api/models/documents.py
Expand Up @@ -16,7 +16,7 @@
from django.urls import reverse
from django.utils import timezone
from allauth.account.utils import user_display
import arrow
from iso8601 import parse_date, ParseError
from taggit.managers import TaggableManager
import reversion.revisions
import reversion.models
Expand Down Expand Up @@ -79,18 +79,18 @@ def get_for_frbr_uri(self, frbr_uri):

elif expr_date[0] == '@':
# document at this date
query = query.filter(expression_date=arrow.get(expr_date[1:]).date())
query = query.filter(expression_date=parse_date(expr_date[1:]).date())

elif expr_date[0] == ':':
# latest document at or before this date
query = query \
.filter(expression_date__lte=arrow.get(expr_date[1:]).date()) \
.filter(expression_date__lte=parse_date(expr_date[1:]).date()) \
.order_by('-expression_date')

else:
raise ValueError("The expression date %s is not valid" % expr_date)

except arrow.parser.ParserError:
except ParseError:
raise ValueError("The expression date %s is not valid" % expr_date)

obj = query.first()
Expand Down Expand Up @@ -330,8 +330,8 @@ def copy_attributes(self, from_model=True):
self.doc.language = self.language.code

self.doc.work_date = self.doc.publication_date
self.doc.expression_date = self.expression_date or self.doc.publication_date or arrow.now()
self.doc.manifestation_date = self.updated_at or arrow.now()
self.doc.expression_date = self.expression_date or self.doc.publication_date or timezone.now()
self.doc.manifestation_date = self.updated_at or timezone.now()
self.doc.publication_number = self.publication_number
self.doc.publication_name = self.publication_name
self.doc.publication_date = self.publication_date
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -41,9 +41,8 @@
python_requires='~=3.6',
install_requires=[
'django>=1.11.27,<2',
'arrow>=0.5',
'boto3>=1.7',
'cobalt>=3.0',
'cobalt>=3.1',
'django-ckeditor>=5.8',
'dj-database-url>=0.3.0',
'django-activity-stream>=0.7.0',
Expand All @@ -70,6 +69,7 @@
'djangorestframework>=3.6.2,<3.7',
'EbookLib>=0.15',
'google-api-python-client>=1.7.9',
'iso8601>=0.1',
'jsonpatch>=1.23',
'libsass==0.14.2', # 0.14.3 upwards changes imports for .css
'lxml>=3.4.1',
Expand Down

0 comments on commit a19c138

Please sign in to comment.