From 1a4c109621df1621c9c7468e034dd54f74e76e00 Mon Sep 17 00:00:00 2001 From: sjanssen2 Date: Tue, 4 Jun 2024 17:36:08 +0200 Subject: [PATCH 1/6] user profile can now also store social handles from google scholar, ORCID and ResearchGate --- qiita_db/support_files/populate_test_db.sql | 8 +- qiita_db/support_files/qiita-db-unpatched.sql | 5 +- qiita_pet/handlers/user_handlers.py | 184 +++++++++++++++++- .../static/img/logo_social_googlescholar.png | Bin 0 -> 7606 bytes qiita_pet/static/img/logo_social_orcid.png | Bin 0 -> 9579 bytes .../static/img/logo_social_researchgate.png | Bin 0 -> 1317 bytes qiita_pet/templates/user_profile.html | 14 +- 7 files changed, 193 insertions(+), 18 deletions(-) create mode 100644 qiita_pet/static/img/logo_social_googlescholar.png create mode 100644 qiita_pet/static/img/logo_social_orcid.png create mode 100644 qiita_pet/static/img/logo_social_researchgate.png diff --git a/qiita_db/support_files/populate_test_db.sql b/qiita_db/support_files/populate_test_db.sql index 12035c788..474d2a3bd 100644 --- a/qiita_db/support_files/populate_test_db.sql +++ b/qiita_db/support_files/populate_test_db.sql @@ -50,10 +50,10 @@ INSERT INTO qiita.user_level VALUES (7, 'wet-lab admin', 'Can access the private -- Data for Name: qiita_user; Type: TABLE DATA; Schema: qiita; Owner: antoniog -- -INSERT INTO qiita.qiita_user VALUES ('test@foo.bar', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Dude', 'Nowhere University', '123 fake st, Apt 0, Faketown, CO 80302', '111-222-3344', NULL, NULL, NULL, false); -INSERT INTO qiita.qiita_user VALUES ('shared@foo.bar', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Shared', 'Nowhere University', '123 fake st, Apt 0, Faketown, CO 80302', '111-222-3344', NULL, NULL, NULL, false); -INSERT INTO qiita.qiita_user VALUES ('admin@foo.bar', 1, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Admin', 'Owner University', '312 noname st, Apt K, Nonexistantown, CO 80302', '222-444-6789', NULL, NULL, NULL, false); -INSERT INTO qiita.qiita_user VALUES ('demo@microbio.me', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Demo', 'Qiita Dev', '1345 Colorado Avenue', '303-492-1984', NULL, NULL, NULL, false); +INSERT INTO qiita.qiita_user VALUES ('test@foo.bar', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Dude', 'Nowhere University', '123 fake st, Apt 0, Faketown, CO 80302', '111-222-3344', NULL, NULL, NULL, false, '0000-0002-0975-9019', 'Rob-Knight', '_e3QL94AAAAJ'); +INSERT INTO qiita.qiita_user VALUES ('shared@foo.bar', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Shared', 'Nowhere University', '123 fake st, Apt 0, Faketown, CO 80302', '111-222-3344', NULL, NULL, NULL, false, NULL, NULL, NULL); +INSERT INTO qiita.qiita_user VALUES ('admin@foo.bar', 1, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Admin', 'Owner University', '312 noname st, Apt K, Nonexistantown, CO 80302', '222-444-6789', NULL, NULL, NULL, false, NULL, NULL, NULL); +INSERT INTO qiita.qiita_user VALUES ('demo@microbio.me', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Demo', 'Qiita Dev', '1345 Colorado Avenue', '303-492-1984', NULL, NULL, NULL, false, NULL, NULL, NULL); -- diff --git a/qiita_db/support_files/qiita-db-unpatched.sql b/qiita_db/support_files/qiita-db-unpatched.sql index 1ce86de39..36e7f1f00 100644 --- a/qiita_db/support_files/qiita-db-unpatched.sql +++ b/qiita_db/support_files/qiita-db-unpatched.sql @@ -1888,7 +1888,10 @@ CREATE TABLE qiita.qiita_user ( user_verify_code character varying, pass_reset_code character varying, pass_reset_timestamp timestamp without time zone, - receive_processing_job_emails boolean DEFAULT false + receive_processing_job_emails boolean DEFAULT false, + social_orcid character varying, + social_researchgate character varying, + social_googlescholar character varying ); diff --git a/qiita_pet/handlers/user_handlers.py b/qiita_pet/handlers/user_handlers.py index 116c69432..01bbca610 100644 --- a/qiita_pet/handlers/user_handlers.py +++ b/qiita_pet/handlers/user_handlers.py @@ -6,8 +6,11 @@ # The full license is in the file LICENSE, distributed with this software. # ----------------------------------------------------------------------------- +import re + from tornado.web import authenticated, HTTPError from wtforms import Form, StringField, BooleanField, validators +from wtforms.validators import ValidationError from qiita_pet.handlers.base_handlers import BaseHandler from qiita_pet.handlers.api_proxy import user_jobs_get_req @@ -21,6 +24,157 @@ class UserProfile(Form): + def validate_general(field: StringField, infomsg: str, url_prefix: str): + """Validate basic user inputs, i.e. check for leading/trailing + whitespaces and leading URL prefix, like http://scholar.google.com/ + + Parameters + ---------- + field : wtforms.StringField + The WTform user input field. + infomsg : str + An error message to inform the user how to extract the correct + value. + url_prefix : str + The URL prefix of the social network + + Returns + ------- + None in case of empty input, otherwise the input value + + Raises + ------ + ValidationError if + a) input has leading or trailing whitespaces + b) input starts with the given url_prefix + """ + value = field.data + if value == "": + # nothing to complain, as input is empty + return None + + if value != value.strip(): + raise ValidationError( + 'Please remove all leading and trailing whitespaces from your ' + 'input.
%s' % infomsg) + + isPrefix = re.search("^%s" % url_prefix, value) + if isPrefix is not None: + raise ValidationError( + 'Please remove the "%s" part from your input.
%s' % ( + isPrefix[0], infomsg)) + + # if there is still no error raised, we return the actual value of the + # user input + return value + + def validator_orcid_id(form: Form, field: StringField): + """A WTForm validator to check if user input follows ORCID syntax. + + Parameters + ---------- + form : wtforms.Form + The WTform form enclosing the user input field. + field : wtforms.StringField + The WTform user input field. + + Returns + ------- + True, if user input is OK. + + Raises + ------ + ValidationError if user input is not valid + """ + infomsg = ('Enter only your 16 digit numerical ORCID identifier, where' + ' every four digits are separated with a dash "-". An ' + 'example is: 0000-0002-0975-9019') + value = UserProfile.validate_general( + field, infomsg, 'https://orcid.org') + if value is None: + return True + + if re.search(r"^\d{4}-\d{4}-\d{4}-\d{4}$", value) is None: + raise ValidationError( + "Your input does not follow the required format.
%s" % + infomsg) + + def validator_gscholar_id(form, field): + """A WTForm validator to check if user input follows google scholar ID + syntax. + + Parameters + ---------- + form : wtforms.Form + The WTform form enclosing the user input field. + field : wtforms.StringField + The WTform user input field. + + Returns + ------- + True, if user input is OK. + + Raises + ------ + ValidationError if user input is not valid + """ + infomsg = ('To retrieve your google scholar ID, surf to your profile ' + 'and copy the URL in your browser. It might read like ' + 'https://scholar.google.com/citations?user=_e3QL94AAAAJ&' + 'hl=en
Ignore everything left of the "?". The right ' + 'part is a set of key=value pairs, separated by "&" ' + 'characters. Find the key "user=", the right part up to ' + 'the next "&" is your google scholar ID, in the example: ' + '"_e3QL94AAAAJ"') + # we need a regex here, since we don't know the TLD the user is + # presenting to us + value = UserProfile.validate_general( + field, infomsg, r'https://scholar.google.\w{1,3}/citations\?') + if value is None: + return True + + if '&' in value: + raise ValidationError( + 'Your input contains multiple key=value pairs (we found at ' + 'least one "&" character).
%s' % infomsg) + if 'user=' in value: + raise ValidationError( + 'Please remove the key "user" and the "=" character from ' + 'your input.
%s' % infomsg) + if value.startswith('='): + raise ValidationError( + 'Please remove leading "=" characters from your input.' + '
%s' % infomsg) + + def validator_rgate_id(form, field): + """A WTForm validator to check if user input follows ResearchGate + user names. + + Parameters + ---------- + form : wtforms.Form + The WTform form enclosing the user input field. + field : wtforms.StringField + The WTform user input field. + + Returns + ------- + True, if user input is OK. + + Raises + ------ + ValidationError if user input is not valid + """ + infomsg = ('To retrieve your ResearchGate ID, surf to your profile ' + 'and copy the URL in your browser. It might read like ' + 'https://www.researchgate.net/profile/Rob-Knight
' + 'Your ID is the part right of the last "/", in the example:' + ' "Rob-Knight"') + value = UserProfile.validate_general( + field, infomsg, 'https://www.researchgate.net/profile/') + if value is None: + return True + name = StringField("Name", [validators.required()]) affiliation = StringField("Affiliation") address = StringField("Address") @@ -28,6 +182,13 @@ class UserProfile(Form): receive_processing_job_emails = BooleanField( "Receive Processing Job Emails?") + social_orcid = StringField( + "ORCID", [validator_orcid_id], description="0000-0002-0975-9019") + social_googlescholar = StringField( + "Google Scholar", [validator_gscholar_id], description="_e3QL94AAAAJ") + social_researchgate = StringField( + "ResearchGate", [validator_rgate_id], description="Rob-Knight") + class UserProfileHandler(BaseHandler): """Displays user profile page and handles profile updates""" @@ -44,11 +205,11 @@ def post(self): msg = "" user = self.current_user action = self.get_argument("action") + form_data = UserProfile() if action == "profile": - # tuple of colmns available for profile + # tuple of columns available for profile # FORM INPUT NAMES MUST MATCH DB COLUMN NAMES not_str_fields = ('receive_processing_job_emails') - form_data = UserProfile() form_data.process(data=self.request.arguments) profile = {name: data[0].decode('ascii') if name not in not_str_fields else @@ -59,16 +220,19 @@ def post(self): for field in form_data: if field.name not in not_str_fields: field.data = field.data[0].decode('ascii') - try: - user.info = profile - msg = "Profile updated successfully" - except Exception as e: - msg = "ERROR: profile could not be updated" - LogEntry.create('Runtime', "Cound not update profile: %s" % - str(e), info={'User': user.id}) + if form_data.validate() is False: + msg = ("ERROR: profile could not be updated" + " as some of your above inputs must be corrected.") + else: + try: + user.info = profile + msg = "Profile updated successfully" + except Exception as e: + msg = "ERROR: profile could not be updated" + LogEntry.create('Runtime', "Cound not update profile: %s" % + str(e), info={'User': user.id}) elif action == "password": - form_data = UserProfile() form_data.process(data=user.info) oldpass = self.get_argument("oldpass") newpass = self.get_argument("newpass") diff --git a/qiita_pet/static/img/logo_social_googlescholar.png b/qiita_pet/static/img/logo_social_googlescholar.png new file mode 100644 index 0000000000000000000000000000000000000000..e9bd65a3acdd866b280f1aa5d1f67f9dd441646c GIT binary patch literal 7606 zcmb7pRX|i-)b^R7hZ-7mXzA{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HHX!;~_|#vzV`4+(GWNn%H; zD|#0KHhr(PFi4D$SuD8jy1v1dr16}foq*w@crVJsq}3oGQmkKCx|nd% z0y?mqS1cD7i6o$UWb(dzGZfUD)Z9|d4JUFd&`!`kn=Mh_ZvPVw8YnkG>%dvXIt=&j zZ^zd(g zxsX_yf76dA5DYc}ExWtyqjAqGqvJ6juMU*|j%5_>1lf}7gm50RwxHmfIf*UK-~>D; z%Su3oO(mB>PX@n z&5q)bz?IRFx{vVxoE<4U;of~4q#r^>MPz!JYMV78PsM-AsHmXh!J_Q+H?Dpv6_p`& z78_C%u|1DXWP+qu5Fim9m0za?&nBcFAmnzbSJ?1Sf>Xb)YET{(f86tv!*9OZWC5wQ z{U`F9lic?b7a|wU`Gjf0)<|6d^b8^$;&0H`WyD%QwbhWsDd0t6%g literal 0 HcmV?d00001 diff --git a/qiita_pet/static/img/logo_social_researchgate.png b/qiita_pet/static/img/logo_social_researchgate.png new file mode 100644 index 0000000000000000000000000000000000000000..23c283b5d408c7a165819fd2d5f7a18e453d2814 GIT binary patch literal 1317 zcmZ`%X;4#F6uvQe352DVmH?I_T0>>i5XLRi4qGayK}=HxwM^Iof>i88Dh_s1mR1Y|+Kb$%DoO{3bo$ovEy_+5w zu+NORfd~LF^Y`;*!fJ0=Mp&4Ai!z#F!9{s7yZ|V_VxkX43=hNom<#~UI{?5-1z-_E zyfFaIQUK7f0if{#u!_%raM%NYb-2KTEIK5B?lMGLipWcGvbTZAL=XXTfl-eLk(Cm9 z4SU=g0V^v7$|BG$!pTL1ZUJPz?UD*XUpY=Dghzs00J;keI27qC$4Z4*sR;j00g;tK zFN6NmyO0C=Z(*UkRD^}#y8+&6{%0iU3%#HYRwjf2q|giM3t@ovJUEQOt6c(V5Xb*3 z1v4~VLx5Bal$8b=?0sMOMyIw^RGb>^d_1eg z%S7M4Y_;vXcSSq!n^tKmziT2d+t4Q=5B#y?S@q7rn$7){Msm?*?LhX#Gp&B%_SEpn zkxu2p%z+zigLnWjp3pk)UoY0~ws1BN z`;`NS)H@Zwlayc{fInE*)Il;QoND)o?x{}Fqg#33c&-l)@!M^S6<@Sh(VPA%2WO1= z)kUn`N9xSc1;u6NJeze;chp#@-ysP7JebY2*WGMJ1mSz<(CNXtecm= z^V%PC?$`-hs;Iv1W(mTHjNn8@MUAM|<&`9&3rJemP#34`Cvir`f&FbyoQX~i4MIUf zLoBnPSxp`D3Z|1CQS|;i-dyh7#!pe%G!~Rj zX4%>IAMg1^6Xt^t+A^EV!nFRLWgPuu7$uqNkmGwOCf|c>$9T@K$Ca@)_tfs3LPCaP zip{kh!ia=(tC`b#qKWM`E;mc7$k$PH#uG;rM~IUvMpJC7*k~q+h4h+M|19Pm!)70V3Zp_yd{ViAV$&Rb$0rss z4xGl*7M##x-g*Q`9X8f(YmGex|16nH58_6IawBQs-$%j%s1z#2)s5=vwu?oj(%ju? pR5xb|g+`&o7q^7`uOaSq#7R!#`x`Lx@x!nI_|pS?%e>ji{{TS`eMA5N literal 0 HcmV?d00001 diff --git a/qiita_pet/templates/user_profile.html b/qiita_pet/templates/user_profile.html index 11eb1a53f..676970d36 100644 --- a/qiita_pet/templates/user_profile.html +++ b/qiita_pet/templates/user_profile.html @@ -14,9 +14,17 @@

User Information

{% for form_item in profile %} -
- - {% raw form_item(class_='form-control') %} +
+
+ {% if form_item.id.startswith('social_') %} + + {% end %} + {% raw form_item.label %} +
+ {% raw form_item(class_='form-control', placeholder=form_item.description) %} + {% if form_item.errors %} +
{% for e in form_item.errors %}{%raw e%}
{% end %}
+ {% end %}
{% end %}
{{msg}}
From 4eaec6551d45d62cb9570bce594f4b4d0fc84af0 Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Tue, 4 Jun 2024 18:43:57 +0200 Subject: [PATCH 2/6] set DEFAULT NULL to new qiita.qiita_user columns --- qiita_db/support_files/populate_test_db.sql | 6 +++--- qiita_db/support_files/qiita-db-unpatched.sql | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/qiita_db/support_files/populate_test_db.sql b/qiita_db/support_files/populate_test_db.sql index 474d2a3bd..46c0aaed7 100644 --- a/qiita_db/support_files/populate_test_db.sql +++ b/qiita_db/support_files/populate_test_db.sql @@ -51,9 +51,9 @@ INSERT INTO qiita.user_level VALUES (7, 'wet-lab admin', 'Can access the private -- INSERT INTO qiita.qiita_user VALUES ('test@foo.bar', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Dude', 'Nowhere University', '123 fake st, Apt 0, Faketown, CO 80302', '111-222-3344', NULL, NULL, NULL, false, '0000-0002-0975-9019', 'Rob-Knight', '_e3QL94AAAAJ'); -INSERT INTO qiita.qiita_user VALUES ('shared@foo.bar', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Shared', 'Nowhere University', '123 fake st, Apt 0, Faketown, CO 80302', '111-222-3344', NULL, NULL, NULL, false, NULL, NULL, NULL); -INSERT INTO qiita.qiita_user VALUES ('admin@foo.bar', 1, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Admin', 'Owner University', '312 noname st, Apt K, Nonexistantown, CO 80302', '222-444-6789', NULL, NULL, NULL, false, NULL, NULL, NULL); -INSERT INTO qiita.qiita_user VALUES ('demo@microbio.me', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Demo', 'Qiita Dev', '1345 Colorado Avenue', '303-492-1984', NULL, NULL, NULL, false, NULL, NULL, NULL); +INSERT INTO qiita.qiita_user VALUES ('shared@foo.bar', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Shared', 'Nowhere University', '123 fake st, Apt 0, Faketown, CO 80302', '111-222-3344', NULL, NULL, NULL, false); +INSERT INTO qiita.qiita_user VALUES ('admin@foo.bar', 1, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Admin', 'Owner University', '312 noname st, Apt K, Nonexistantown, CO 80302', '222-444-6789', NULL, NULL, NULL, false); +INSERT INTO qiita.qiita_user VALUES ('demo@microbio.me', 4, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Demo', 'Qiita Dev', '1345 Colorado Avenue', '303-492-1984', NULL, NULL, NULL, false); -- diff --git a/qiita_db/support_files/qiita-db-unpatched.sql b/qiita_db/support_files/qiita-db-unpatched.sql index 36e7f1f00..a61b4645d 100644 --- a/qiita_db/support_files/qiita-db-unpatched.sql +++ b/qiita_db/support_files/qiita-db-unpatched.sql @@ -1889,9 +1889,9 @@ CREATE TABLE qiita.qiita_user ( pass_reset_code character varying, pass_reset_timestamp timestamp without time zone, receive_processing_job_emails boolean DEFAULT false, - social_orcid character varying, - social_researchgate character varying, - social_googlescholar character varying + social_orcid character varying DEFAULT NULL, + social_researchgate character varying DEFAULT NULL, + social_googlescholar character varying DEFAULT NULL ); From 405181a05a5958c6feb7641dc4a2569a70a33efc Mon Sep 17 00:00:00 2001 From: sjanssen2 Date: Tue, 4 Jun 2024 19:09:10 +0200 Subject: [PATCH 3/6] extending existing test --- qiita_pet/test/test_user_handlers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qiita_pet/test/test_user_handlers.py b/qiita_pet/test/test_user_handlers.py index b0724eba6..53c073d1c 100644 --- a/qiita_pet/test/test_user_handlers.py +++ b/qiita_pet/test/test_user_handlers.py @@ -37,7 +37,10 @@ def test_post_profile(self): 'affiliation': ['NEWNAME'], 'address': ['ADDRESS'], 'name': ['TESTDUDE'], - 'phone': ['111-222-3333']} + 'phone': ['111-222-3333'], + 'social_orcid': [''], + 'social_googlescholar': [''], + 'social_researchgate': ['']} response = self.post('/profile/', post_args) self.assertEqual(response.code, 200) From b067cdae90a3bf5402e405565229941abb7e8cdb Mon Sep 17 00:00:00 2001 From: Stefan Janssen Date: Tue, 4 Jun 2024 20:41:15 +0200 Subject: [PATCH 4/6] extending tests --- qiita_db/test/test_user.py | 20 ++++++++++++++++---- qiita_db/test/test_util.py | 3 ++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/qiita_db/test/test_user.py b/qiita_db/test/test_user.py index 2dced88d9..666746c36 100644 --- a/qiita_db/test/test_user.py +++ b/qiita_db/test/test_user.py @@ -72,7 +72,10 @@ def setUp(self): 'pass_reset_code': None, 'pass_reset_timestamp': None, 'user_verify_code': None, - 'receive_processing_job_emails': True + 'receive_processing_job_emails': True, + 'social_orcid': None, + 'social_researchgate': None, + 'social_googlescholar': None } def tearDown(self): @@ -125,7 +128,10 @@ def test_create_user(self): 'address': None, 'user_level_id': 5, 'receive_processing_job_emails': False, - 'email': 'testcreateuser@test.bar'} + 'email': 'testcreateuser@test.bar', + 'social_orcid': None, + 'social_researchgate': None, + 'social_googlescholar': None} self._check_correct_info(obs, exp) # Make sure new system messages are linked to user @@ -162,7 +168,10 @@ def test_create_user_info(self): 'user_verify_code': '', 'user_level_id': 5, 'receive_processing_job_emails': True, - 'email': 'testcreateuserinfo@test.bar'} + 'email': 'testcreateuserinfo@test.bar', + 'social_orcid': None, + 'social_researchgate': None, + 'social_googlescholar': None} self._check_correct_info(obs, exp) def test_create_user_column_not_allowed(self): @@ -229,7 +238,10 @@ def test_get_info(self): 'pass_reset_timestamp': None, 'user_verify_code': None, 'receive_processing_job_emails': False, - 'phone': '222-444-6789' + 'phone': '222-444-6789', + 'social_orcid': None, + 'social_researchgate': None, + 'social_googlescholar': None } self.assertEqual(self.user.info, expinfo) diff --git a/qiita_db/test/test_util.py b/qiita_db/test/test_util.py index a8df7ed3c..26fff3004 100644 --- a/qiita_db/test/test_util.py +++ b/qiita_db/test/test_util.py @@ -92,7 +92,8 @@ def test_get_table_cols(self): obs = qdb.util.get_table_cols("qiita_user") exp = {"email", "user_level_id", "password", "name", "affiliation", "address", "phone", "user_verify_code", "pass_reset_code", - "pass_reset_timestamp", "receive_processing_job_emails"} + "pass_reset_timestamp", "receive_processing_job_emails", + "social_orcid", "social_researchgate", "social_googlescholar"} self.assertEqual(set(obs), exp) def test_exists_table(self): From 54772cf1567409e989d2b4548ce5a0e907fcb547 Mon Sep 17 00:00:00 2001 From: sjanssen2 Date: Tue, 4 Jun 2024 21:27:05 +0200 Subject: [PATCH 5/6] add tests for validator functions for WTform StringFields --- qiita_pet/test/test_user_handlers.py | 75 +++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/qiita_pet/test/test_user_handlers.py b/qiita_pet/test/test_user_handlers.py index 53c073d1c..42fd46d8a 100644 --- a/qiita_pet/test/test_user_handlers.py +++ b/qiita_pet/test/test_user_handlers.py @@ -7,8 +7,11 @@ # ----------------------------------------------------------------------------- from unittest import main +from wtforms.validators import ValidationError +from wtforms import StringField from qiita_pet.test.tornado_test_base import TestHandlerBase +from qiita_pet.handlers.user_handlers import UserProfile class TestUserProfile(TestHandlerBase): @@ -17,7 +20,6 @@ class TestUserProfile(TestHandlerBase): class TestUserProfileHandler(TestHandlerBase): - def test_get(self): response = self.get('/profile/') self.assertEqual(response.code, 200) @@ -44,6 +46,77 @@ def test_post_profile(self): response = self.post('/profile/', post_args) self.assertEqual(response.code, 200) + def test_validators_social(self): + # None or empty should be valid + obs = UserProfile.validate_general(None, "", "") + self.assertEqual(obs, None) + obs = UserProfile.validate_general("", "", "") + self.assertEqual(obs, None) + + # having white spaces should raise errors + with self.assertRaises(ValidationError): + obs = UserProfile.validate_general(" infix", "", "") + with self.assertRaises(ValidationError): + obs = UserProfile.validate_general("infix ", "", "") + with self.assertRaises(ValidationError): + obs = UserProfile.validate_general(" infix ", "", "") + obs = UserProfile.validate_general("infix", "", "") + self.assertEqual(obs, 'infix') + + with self.assertRaises(ValidationError): + obs = UserProfile.validate_general( + "http://kurt.com/id1234", "msg", r"http://kurt.\w{1,3}/") + + def test_validator_orcid_id(self): + field = StringField("testfield") + + field.data = "0000-0002-0975-9019" + obs = UserProfile.validator_orcid_id(None, field) + self.assertEqual(obs, None) + + field.data = "https://orcid.org/0000-0002-0975-9019" + with self.assertRaises(ValidationError): + obs = UserProfile.validator_orcid_id(None, field) + + field.data = "wrong" + with self.assertRaises(ValidationError): + obs = UserProfile.validator_orcid_id(None, field) + + def test_validator_gscholar_id(self): + field = StringField("testfield") + + field.data = "_e3QL94AAAAJ" + obs = UserProfile.validator_gscholar_id(None, field) + self.assertEqual(obs, None) + + field.data = ('https://scholar.google.com/citations?user=_e3QL94AAAAJ&' + 'hl=en') + with self.assertRaises(ValidationError): + obs = UserProfile.validator_gscholar_id(None, field) + + field.data = 'user=_e3QL94AAAAJ&hl=en' + with self.assertRaises(ValidationError): + obs = UserProfile.validator_gscholar_id(None, field) + + field.data = 'user=_e3QL94AAAAJ' + with self.assertRaises(ValidationError): + obs = UserProfile.validator_gscholar_id(None, field) + + field.data = '=_e3QL94AAAAJ' + with self.assertRaises(ValidationError): + obs = UserProfile.validator_gscholar_id(None, field) + + def test_validator_rgate_id(self): + field = StringField("testfield") + + field.data = "Rob-Knight" + obs = UserProfile.validator_rgate_id(None, field) + self.assertEqual(obs, None) + + field.data = 'https://www.researchgate.net/profile/Rob-Knight' + with self.assertRaises(ValidationError): + obs = UserProfile.validator_rgate_id(None, field) + class TestUserJobsHandler(TestHandlerBase): def test_get(self): From 8a0daec6ae94e1f7836d672d131f51605f2f984b Mon Sep 17 00:00:00 2001 From: sjanssen2 Date: Tue, 4 Jun 2024 21:28:17 +0200 Subject: [PATCH 6/6] operate on str instead of field.data --- qiita_pet/handlers/user_handlers.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/qiita_pet/handlers/user_handlers.py b/qiita_pet/handlers/user_handlers.py index 01bbca610..d75316a80 100644 --- a/qiita_pet/handlers/user_handlers.py +++ b/qiita_pet/handlers/user_handlers.py @@ -24,14 +24,14 @@ class UserProfile(Form): - def validate_general(field: StringField, infomsg: str, url_prefix: str): + def validate_general(value: str, infomsg: str, url_prefix: str): """Validate basic user inputs, i.e. check for leading/trailing whitespaces and leading URL prefix, like http://scholar.google.com/ Parameters ---------- - field : wtforms.StringField - The WTform user input field. + value : str + The WTform user input string. infomsg : str An error message to inform the user how to extract the correct value. @@ -48,8 +48,7 @@ def validate_general(field: StringField, infomsg: str, url_prefix: str): a) input has leading or trailing whitespaces b) input starts with the given url_prefix """ - value = field.data - if value == "": + if (value is None) or (value == ""): # nothing to complain, as input is empty return None @@ -58,11 +57,12 @@ def validate_general(field: StringField, infomsg: str, url_prefix: str): 'Please remove all leading and trailing whitespaces from your ' 'input.
%s' % infomsg) - isPrefix = re.search("^%s" % url_prefix, value) - if isPrefix is not None: - raise ValidationError( - 'Please remove the "%s" part from your input.
%s' % ( - isPrefix[0], infomsg)) + if len(url_prefix) > 0: + isPrefix = re.search("^%s" % url_prefix, value) + if isPrefix is not None: + raise ValidationError( + 'Please remove the "%s" part from your input.
%s' % ( + isPrefix[0], infomsg)) # if there is still no error raised, we return the actual value of the # user input @@ -90,7 +90,7 @@ def validator_orcid_id(form: Form, field: StringField): ' every four digits are separated with a dash "-". An ' 'example is: 0000-0002-0975-9019') value = UserProfile.validate_general( - field, infomsg, 'https://orcid.org') + field.data, infomsg, 'https://orcid.org') if value is None: return True @@ -129,7 +129,7 @@ def validator_gscholar_id(form, field): # we need a regex here, since we don't know the TLD the user is # presenting to us value = UserProfile.validate_general( - field, infomsg, r'https://scholar.google.\w{1,3}/citations\?') + field.data, infomsg, r'https://scholar.google.\w{1,3}/citations\?') if value is None: return True @@ -171,7 +171,7 @@ def validator_rgate_id(form, field): 'Your ID is the part right of the last "/", in the example:' ' "Rob-Knight"') value = UserProfile.validate_general( - field, infomsg, 'https://www.researchgate.net/profile/') + field.data, infomsg, 'https://www.researchgate.net/profile/') if value is None: return True