-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ElementsAPICall model with a celery task to patch update an E… (
#173) Replace ElementsAPICall model with a celery task to patch update an Elements record. Delete elements models and make database migration. Update tests.
- Loading branch information
Showing
15 changed files
with
318 additions
and
639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .celery import app as celery_app | ||
|
||
__all__ = ('celery_app',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
|
||
from celery import Celery | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'solenoid.settings.base') | ||
|
||
app = Celery('solenoid') | ||
app.config_from_object('django.conf:settings', namespace='CELERY') | ||
app.autodiscover_tasks() | ||
|
||
|
||
@app.task(bind=True) | ||
def debug_task(self): | ||
print('Request: {0!r}'.format(self.request)) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Error(Exception): | ||
"""Base class for exceptions in this module.""" | ||
pass | ||
|
||
|
||
class RetryError(Error): | ||
"""Exception raised for HTTP status codes that indicate a Symplectic | ||
Elements API call should be retried (409, 500, 504). | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from xml.etree.ElementTree import Element, SubElement | ||
|
||
from django.utils import timezone | ||
|
||
|
||
def make_xml(username): | ||
top = Element('update-object') | ||
top.set('xmlns', 'http://www.symplectic.co.uk/publications/api') | ||
oa_field = SubElement(top, 'oa') | ||
|
||
# Update library status field | ||
status_field = SubElement(oa_field, 'library-status') | ||
status_field.set('status', 'full-text-requested') | ||
date_field = SubElement(status_field, 'last-requested-when') | ||
date_field.text = timezone.now().isoformat() | ||
note_field = SubElement(status_field, 'note-field') | ||
note_field.set('clear-existing-note', 'true') | ||
note = SubElement(note_field, 'note') | ||
note.text = "Library status changed to Full text requested on " \ | ||
"{date} by {username}.".format( | ||
date=timezone.now().strftime('%-d %B %Y'), | ||
username=username) | ||
|
||
return top |
21 changes: 0 additions & 21 deletions
21
solenoid/elements/management/commands/delete_stale_api_calls.py
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
solenoid/elements/management/commands/issue_unsent_calls.py
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
solenoid/elements/migrations/0003_delete_elementsapicall.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Generated by Django 2.2.7 on 2019-11-21 19:56 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('elements', '0002_auto_20180308_1812'), | ||
] | ||
|
||
operations = [ | ||
migrations.DeleteModel( | ||
name='ElementsAPICall', | ||
), | ||
] |
Oops, something went wrong.