summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/forms.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-03-21 16:59:18 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-03-21 16:59:18 -0700
commit5527ecc2b7bd81bab9bcb065adbbccd941b85be8 (patch)
treee8b01a20ee147858408c4058c707638a35649c1c /python/fatcat_web/forms.py
parent1f165c34a6179f96b6de0c616f21a319e3c4ccce (diff)
downloadfatcat-5527ecc2b7bd81bab9bcb065adbbccd941b85be8.tar.gz
fatcat-5527ecc2b7bd81bab9bcb065adbbccd941b85be8.zip
major progress on release create form
Diffstat (limited to 'python/fatcat_web/forms.py')
-rw-r--r--python/fatcat_web/forms.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/python/fatcat_web/forms.py b/python/fatcat_web/forms.py
new file mode 100644
index 00000000..f961faa0
--- /dev/null
+++ b/python/fatcat_web/forms.py
@@ -0,0 +1,81 @@
+
+"""
+Note: in thoery could use, eg, https://github.com/christabor/swagger_wtforms,
+but can't find one that is actually maintained.
+"""
+
+from flask_wtf import FlaskForm
+from wtforms import SelectField, DateField, StringField, FormField, FieldList, validators
+
+release_type_options = [
+ ('article-journal', 'Journal Article'),
+ ('paper-conference', 'Conference Proceeding'),
+ ('article', 'Article (non-journal)'),
+ ('book', 'Book'),
+ ('chapter', 'Book Chapter'),
+ ('dataset', 'Dataset'),
+ ('stub', 'Invalid/Stub'),
+]
+release_status_options = [
+ ('draft', 'Draft'),
+ ('submitted', 'Submitted'),
+ ('accepted', 'Accepted'),
+ ('published', 'Published'),
+ ('updated', 'Updated'),
+]
+role_type_options = [
+ ('author', 'Author'),
+ ('editor', 'Editor'),
+ ('translator', 'Translator'),
+]
+
+class EntityEditForm(FlaskForm):
+ editgroup_id = StringField('Editgroup ID',
+ [validators.DataRequired()])
+ editgroup_description = StringField('Editgroup Description',
+ [validators.Optional(True)])
+ edit_description = StringField('Description of Changes',
+ [validators.Optional(True)])
+
+class ReleaseContribForm(FlaskForm):
+ #surname
+ #given_name
+ #creator_id (?)
+ #orcid (for match?)
+ raw_name = StringField('Display Name')
+ role = SelectField(choices=role_type_options)
+
+class ReleaseEntityForm(EntityEditForm):
+ """
+ TODO:
+ - field types: fatcat id
+ - date
+ """
+ title = StringField('Title', [validators.InputRequired()])
+ original_title = StringField('Original Title')
+ work_id = StringField('Work FCID')
+ container_id = StringField('Container FCID')
+ release_type = SelectField(choices=release_type_options)
+ release_status = SelectField(choices=release_status_options)
+ release_date = DateField('Release Date',
+ [validators.Optional(True)])
+ #release_year
+ doi = StringField('DOI',
+ [validators.Regexp('^10\..*\/.*', message="DOI must be valid")])
+ wikidata_qid = StringField('Wikidata QID')
+ isbn13 = StringField('ISBN-13')
+ pmid = StringField('PubMed Id')
+ pmcid = StringField('PubMed Central Id')
+ #core_id
+ #arxiv_id
+ #jstor_id
+ volume = StringField('Volume')
+ issue = StringField('Issue')
+ pages = StringField('Pages')
+ publisher = StringField('Publisher (optional)')
+ language = StringField('Language (code)')
+ license_slug = StringField('License (slug)')
+ contribs = FieldList(FormField(ReleaseContribForm))
+ #refs
+ #abstracts
+