From 285eddcf04950ecbcf2de9d8b9c54dd0d4afb00c Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 20 Jul 2018 21:02:21 -0700 Subject: python updates for identifier changes --- python/README_codegen.md | 6 +++--- python/fatcat/importer_common.py | 9 ++++++--- python/fatcat/routes.py | 16 ++++++++-------- python/fatcat/templates/container_view.html | 3 ++- python/fatcat/templates/creator_view.html | 3 ++- python/fatcat/templates/editor_view.html | 3 +-- python/fatcat/templates/file_view.html | 3 ++- python/fatcat/templates/release_view.html | 3 ++- python/fatcat/templates/work_view.html | 3 ++- python/tests/routes.py | 8 ++++---- 10 files changed, 32 insertions(+), 25 deletions(-) (limited to 'python') diff --git a/python/README_codegen.md b/python/README_codegen.md index 71e56fa0..9d9bdb52 100644 --- a/python/README_codegen.md +++ b/python/README_codegen.md @@ -52,7 +52,7 @@ from fatcat_client.rest import ApiException from pprint import pprint # create an instance of the API class api_instance = fatcat_client.DefaultApi() -id = 789 # int | +id = 'id_example' # str | try: api_response = api_instance.accept_editgroup(id) @@ -88,8 +88,8 @@ Class | Method | HTTP request | Description *DefaultApi* | [**get_creator_history**](docs/DefaultApi.md#get_creator_history) | **GET** /creator/{id}/history | *DefaultApi* | [**get_creator_releases**](docs/DefaultApi.md#get_creator_releases) | **GET** /creator/{id}/releases | *DefaultApi* | [**get_editgroup**](docs/DefaultApi.md#get_editgroup) | **GET** /editgroup/{id} | -*DefaultApi* | [**get_editor**](docs/DefaultApi.md#get_editor) | **GET** /editor/{username} | -*DefaultApi* | [**get_editor_changelog**](docs/DefaultApi.md#get_editor_changelog) | **GET** /editor/{username}/changelog | +*DefaultApi* | [**get_editor**](docs/DefaultApi.md#get_editor) | **GET** /editor/{id} | +*DefaultApi* | [**get_editor_changelog**](docs/DefaultApi.md#get_editor_changelog) | **GET** /editor/{id}/changelog | *DefaultApi* | [**get_file**](docs/DefaultApi.md#get_file) | **GET** /file/{id} | *DefaultApi* | [**get_file_history**](docs/DefaultApi.md#get_file_history) | **GET** /file/{id}/history | *DefaultApi* | [**get_release**](docs/DefaultApi.md#get_release) | **GET** /release/{id} | diff --git a/python/fatcat/importer_common.py b/python/fatcat/importer_common.py index 6f867f70..9d495aa7 100644 --- a/python/fatcat/importer_common.py +++ b/python/fatcat/importer_common.py @@ -27,19 +27,22 @@ class FatcatImporter: def process_source(self, source, group_size=100): """Creates and auto-accepts editgroup every group_size rows""" - eg = self.api.create_editgroup(fatcat_client.Editgroup(editor_id=1)) + eg = self.api.create_editgroup( + fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae')) for i, row in enumerate(source): self.create_row(row, editgroup_id=eg.id) if i > 0 and (i % group_size) == 0: self.api.accept_editgroup(eg) - eg = self.api.create_editgroup(fatcat_client.Editgroup(editor_id=1)) + eg = self.api.create_editgroup( + fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae')) if i == 0 or (i % group_size) != 0: self.api.accept_editgroup(eg.id) def process_batch(self, source, size=50): """Reads and processes in batches (not API-call-per-)""" for rows in grouper(source, size): - eg = self.api.create_editgroup(fatcat_client.Editgroup(editor_id=1)) + eg = self.api.create_editgroup( + fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae')) self.create_batch(rows, eg.id) self.api.accept_editgroup(eg.id) diff --git a/python/fatcat/routes.py b/python/fatcat/routes.py index c92f6493..209a7676 100644 --- a/python/fatcat/routes.py +++ b/python/fatcat/routes.py @@ -257,7 +257,7 @@ def editgroup_current(): #eg = api.get_or_create_editgroup() #return redirect('/editgroup/{}'.format(eg.id)) -@app.route('/editgroup/', methods=['GET']) +@app.route('/editgroup/', methods=['GET']) def editgroup_view(ident): try: entity = api.get_editgroup(str(ident)) @@ -266,15 +266,15 @@ def editgroup_view(ident): abort(ae.status) return render_template('editgroup_view.html', editgroup=entity) -@app.route('/editor/', methods=['GET']) -def editor_view(username): - entity = api.get_editor(username) +@app.route('/editor/', methods=['GET']) +def editor_view(ident): + entity = api.get_editor(ident) return render_template('editor_view.html', editor=entity) -@app.route('/editor//changelog', methods=['GET']) -def editor_changelog(username): - editor = api.get_editor(username) - changelog_entries = api.get_editor_changelog(username) +@app.route('/editor//changelog', methods=['GET']) +def editor_changelog(ident): + editor = api.get_editor(ident) + changelog_entries = api.get_editor_changelog(ident) return render_template('editor_changelog.html', editor=editor, changelog_entries=changelog_entries) diff --git a/python/fatcat/templates/container_view.html b/python/fatcat/templates/container_view.html index e65b65b1..bcdbfc95 100644 --- a/python/fatcat/templates/container_view.html +++ b/python/fatcat/templates/container_view.html @@ -89,7 +89,8 @@ Raw Object:
Fatcat Bits -

Revision #{{ container.revision }}. State is "{{ container.state }}" +

State is "{{ container.state }}". Revision: +
{{ container.revision }}
As JSON object via API

diff --git a/python/fatcat/templates/creator_view.html b/python/fatcat/templates/creator_view.html index 91c0ee52..3047a909 100644 --- a/python/fatcat/templates/creator_view.html +++ b/python/fatcat/templates/creator_view.html @@ -63,7 +63,8 @@ Raw Object:
Fatcat Bits -

Revision #{{ creator.revision }}. State is "{{ creator.state }}" +

State is "{{ creator.state }}". Revision: +
{{ creator.revision }}
As JSON object via API

diff --git a/python/fatcat/templates/editor_view.html b/python/fatcat/templates/editor_view.html index f58b85b5..c9b61f5d 100644 --- a/python/fatcat/templates/editor_view.html +++ b/python/fatcat/templates/editor_view.html @@ -7,7 +7,6 @@ -

Is Admin? {{ editor.is_admin }} -

Changelog +

View editor's changelog {% endblock %} diff --git a/python/fatcat/templates/file_view.html b/python/fatcat/templates/file_view.html index 8ded9ced..54a6c18a 100644 --- a/python/fatcat/templates/file_view.html +++ b/python/fatcat/templates/file_view.html @@ -90,7 +90,8 @@ Raw Object: {% endif %} Fatcat Bits -

Revision #{{ file.revision }}. State is "{{ file.state }}" +

State is "{{ file.state }}". Revision: +
{{ file.revision }}
As JSON object via API diff --git a/python/fatcat/templates/release_view.html b/python/fatcat/templates/release_view.html index 22a45e15..b3fe0aa6 100644 --- a/python/fatcat/templates/release_view.html +++ b/python/fatcat/templates/release_view.html @@ -223,7 +223,8 @@ This release citing other releases.

Fatcat Bits -

Revision #{{ release.revision }}. State is "{{ release.state }}" +

State is "{{ release.state }}". Revision: +
{{ release.revision }}
As JSON object via API

diff --git a/python/fatcat/templates/work_view.html b/python/fatcat/templates/work_view.html index ced19397..afee760e 100644 --- a/python/fatcat/templates/work_view.html +++ b/python/fatcat/templates/work_view.html @@ -56,7 +56,8 @@ still reference the same underlying "work".
Fatcat Bits -

Revision #{{ work.revision }}. State is "{{ work.state }}" +

State is "{{ work.state }}". Revision: +
{{ work.revision }}
As JSON object via API

diff --git a/python/tests/routes.py b/python/tests/routes.py index 3391596e..8607e7c0 100644 --- a/python/tests/routes.py +++ b/python/tests/routes.py @@ -99,10 +99,10 @@ def test_all_views(app): rv = app.get('/work/create') assert rv.status_code == 404 - rv = app.get('/editgroup/1') + rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaae') assert rv.status_code == 200 - rv = app.get('/editgroup/99999999') + rv = app.get('/editgroup/ccccccccccccccccccccccccca') print(rv) print(rv.data) assert rv.status_code == 404 @@ -110,10 +110,10 @@ def test_all_views(app): #rv = app.get('/editgroup/current') #assert rv.status_code == 302 - rv = app.get('/editor/admin') + rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae') assert rv.status_code == 200 - rv = app.get('/editor/admin/changelog') + rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae/changelog') assert rv.status_code == 200 rv = app.get('/stats') -- cgit v1.2.3