aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web
diff options
context:
space:
mode:
authorMartin Czygan <martin@archive.org>2020-07-10 21:32:41 +0000
committerMartin Czygan <martin@archive.org>2020-07-10 21:32:41 +0000
commit3c266e07771271241aa8cff3e3199a45109362af (patch)
tree73fa6aedf1bbfeffeac9c94593f5f9c4f2dd645b /python/fatcat_web
parentfdf1028c19b0623e30b91e49ffa65ed130dcfdc1 (diff)
parentc9d8550be4bab808c2bad0b0d3642a71075202c0 (diff)
downloadfatcat-3c266e07771271241aa8cff3e3199a45109362af.tar.gz
fatcat-3c266e07771271241aa8cff3e3199a45109362af.zip
datacite: resolve formatting issues in tests
Diffstat (limited to 'python/fatcat_web')
-rw-r--r--python/fatcat_web/auth.py6
-rw-r--r--python/fatcat_web/editing_routes.py22
-rw-r--r--python/fatcat_web/forms.py5
-rw-r--r--python/fatcat_web/graphics.py1
-rw-r--r--python/fatcat_web/routes.py7
-rw-r--r--python/fatcat_web/search.py3
-rw-r--r--python/fatcat_web/web_config.py1
7 files changed, 18 insertions, 27 deletions
diff --git a/python/fatcat_web/auth.py b/python/fatcat_web/auth.py
index 8e26b7fe..ed9f2252 100644
--- a/python/fatcat_web/auth.py
+++ b/python/fatcat_web/auth.py
@@ -2,8 +2,7 @@
from collections import namedtuple
import requests
import pymacaroons
-from flask import Flask, render_template, send_from_directory, request, \
- url_for, abort, g, redirect, jsonify, session, flash
+from flask import render_template, abort, redirect, session, flash
from flask_login import logout_user, login_user, UserMixin
from fatcat_web import login_manager, app, api, priv_api, Config
import fatcat_openapi_client
@@ -141,8 +140,9 @@ def handle_wmoauth(username):
# pass off "as if" we did OAuth successfully
FakeOAuthRemote = namedtuple('FakeOAuthRemote', ['name', 'OAUTH_CONFIG'])
remote = FakeOAuthRemote(name='wikipedia', OAUTH_CONFIG={'api_base_url': "https://www.mediawiki.org/w"})
+ conservative_username = ''.join(filter(str.isalnum, username))
oauth_info = {
- 'preferred_username': username,
+ 'preferred_username': conservative_username,
'iss': "https://www.mediawiki.org/w",
'sub': username,
}
diff --git a/python/fatcat_web/editing_routes.py b/python/fatcat_web/editing_routes.py
index 87223868..44000b1a 100644
--- a/python/fatcat_web/editing_routes.py
+++ b/python/fatcat_web/editing_routes.py
@@ -1,16 +1,11 @@
-import os
-import json
-from flask import Flask, render_template, send_from_directory, request, \
- url_for, abort, g, redirect, jsonify, session, flash, Response
+from flask import render_template, abort, redirect, session, flash
from flask_login import login_required
from fatcat_openapi_client import Editgroup
from fatcat_openapi_client.rest import ApiException
from fatcat_tools.transforms import *
-from fatcat_web import app, api, auth_api, priv_api
-from fatcat_web.auth import handle_token_login, handle_logout, load_user, handle_ia_xauth
-from fatcat_web.cors import crossdomain
+from fatcat_web import app, api, auth_api
from fatcat_web.search import *
from fatcat_web.forms import *
from fatcat_web.entity_helpers import *
@@ -20,7 +15,7 @@ from fatcat_web.entity_helpers import *
def form_editgroup_get_or_create(api, edit_form):
"""
- This function expects a submitted, validated
+ This function expects a submitted, validated edit form
"""
if edit_form.editgroup_id.data:
try:
@@ -43,8 +38,10 @@ def form_editgroup_get_or_create(api, edit_form):
app.log.warning(ae)
abort(ae.status)
# set this session editgroup_id
- flash('Started new editgroup <a href="/editgroup/{}">{}</a>' \
- .format(eg.editgroup_id, eg.editgroup_id))
+ flash('Started new editgroup <a href="/editgroup/{}">{}</a>'.format(
+ eg.editgroup_id,
+ eg.editgroup_id,
+ ))
return eg
def generic_entity_edit(editgroup_id, entity_type, existing_ident, edit_template):
@@ -68,7 +65,7 @@ def generic_entity_edit(editgroup_id, entity_type, existing_ident, edit_template
Helpers:
- get_editgroup_revision(editgroup, entity_type, ident) -> None or entity
-
+
TODO: prev_rev interlock
"""
@@ -214,7 +211,7 @@ def generic_edit_delete(editgroup_id, entity_type, edit_id):
# API on behalf of user
user_api = auth_api(session['api_token'])
-
+
# do the deletion
try:
if entity_type == 'container':
@@ -358,4 +355,3 @@ def work_editgroup_edit(editgroup_id, ident):
@app.route('/editgroup/<editgroup_id>/work/edit/<edit_id>/delete', methods=['POST'])
def work_edit_delete(editgroup_id, edit_id):
return abort(404)
-
diff --git a/python/fatcat_web/forms.py b/python/fatcat_web/forms.py
index 377e35aa..15585bf6 100644
--- a/python/fatcat_web/forms.py
+++ b/python/fatcat_web/forms.py
@@ -8,7 +8,7 @@ from flask_wtf import FlaskForm
from wtforms import SelectField, DateField, StringField, IntegerField, \
HiddenField, FormField, FieldList, validators
-from fatcat_openapi_client import ContainerEntity, CreatorEntity, FileEntity, \
+from fatcat_openapi_client import ContainerEntity, FileEntity, \
ReleaseEntity, ReleaseContrib, FileUrl, ReleaseExtIds
release_type_options = [
@@ -293,9 +293,9 @@ class FileUrlForm(FlaskForm):
default='web')
class FileEntityForm(EntityEditForm):
+ # TODO: positive definite
size = IntegerField('Size (bytes)',
[validators.DataRequired()])
- # TODO: positive definite
md5 = StringField("MD5",
[validators.Optional(True),
validators.Length(min=32, max=32)])
@@ -413,4 +413,3 @@ class SavePaperNowForm(FlaskForm):
ingest_request['link_source'] = 'arxiv'
ingest_request['link_source_id'] = release.ext_ids.arxiv
return ingest_request
-
diff --git a/python/fatcat_web/graphics.py b/python/fatcat_web/graphics.py
index fea7eb5a..56852627 100644
--- a/python/fatcat_web/graphics.py
+++ b/python/fatcat_web/graphics.py
@@ -33,4 +33,3 @@ def ia_coverage_histogram(rows):
chart.add('via Fatcat', [y['available'] for y in years])
chart.add('Missing', [y['missing'] for y in years])
return chart
-
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index 58f4b7e0..4684f799 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -2,12 +2,12 @@
import os
import sys
import json
-from flask import Flask, render_template, make_response, send_from_directory, \
- request, url_for, abort, g, redirect, jsonify, session, flash, Response
+from flask import render_template, make_response, send_from_directory, \
+ request, url_for, abort, redirect, jsonify, session, flash, Response
from flask_login import login_required
from flask_wtf.csrf import CSRFError
-from fatcat_openapi_client import Editgroup, EditgroupAnnotation
+from fatcat_openapi_client import EditgroupAnnotation
from fatcat_openapi_client.rest import ApiException
from fatcat_tools.transforms import *
from fatcat_tools.normal import *
@@ -1042,4 +1042,3 @@ def robots():
return send_from_directory(os.path.join(app.root_path, 'static'),
'robots.txt',
mimetype='text/plain')
-
diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py
index c1246d22..4a87c735 100644
--- a/python/fatcat_web/search.py
+++ b/python/fatcat_web/search.py
@@ -66,7 +66,6 @@ def do_release_search(q, limit=30, fulltext_only=True, offset=0):
if len(q.split()) == 1 and q.startswith("10.") and q.count("/") >= 1:
q = 'doi:"{}"'.format(q)
-
if fulltext_only:
q += " in_web:true"
@@ -297,7 +296,7 @@ def get_elastic_container_random_releases(ident, limit=5):
def get_elastic_container_histogram(ident):
"""
- Fetches a stacked histogram of
+ Fetches a stacked histogram
Filters to the past 500 years (at most), or about 1000 values.
diff --git a/python/fatcat_web/web_config.py b/python/fatcat_web/web_config.py
index 0cb153d6..344f1c2a 100644
--- a/python/fatcat_web/web_config.py
+++ b/python/fatcat_web/web_config.py
@@ -83,4 +83,3 @@ class Config(object):
'fatcat_domain': FATCAT_DOMAIN,
},
}
-