Skip to content

Commit

Permalink
support: added contact form
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandromumo committed Nov 11, 2022
1 parent 670d487 commit 7eb327c
Show file tree
Hide file tree
Showing 27 changed files with 1,401 additions and 9 deletions.
20 changes: 19 additions & 1 deletion assets/less/zenodo-rdm/globals/site.overrides
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,22 @@ body {
.spaced-left {
margin-left: 0.3em;
}
}
}

#contact-page {

.ui.container {
padding: 15px
}

.content-tab {
margin-bottom: 10px;
min-height: 40px;
}

.panel-body {
padding-top: @cover-panel-padding;
padding-left: @cover-panel-padding;
}
}

2 changes: 2 additions & 0 deletions assets/less/zenodo-rdm/globals/site.variables
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@
@bold: 700;

@headerFontWeight: @semibold;

@cover-panel-padding: 40px;
7 changes: 7 additions & 0 deletions site/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ zip_safe = False
[options.extras_require]
tests =
pytest-invenio>=2.1.0,<3.0.0
pytest-black>=0.3.0
sphinx>=4.5
invenio-access>=1.0.0,<2.0.0
invenio-app>=1.3.4,<2.0.0

[options.entry_points]
invenio_base.blueprints =
Expand Down Expand Up @@ -52,3 +56,6 @@ output-dir = zenodo_rdm/translations/
[update_catalog]
input-file = zenodo_rdm/translations/messages.pot
output-dir = zenodo_rdm/translations/

[tool:pytest]
addopts = --black --isort --pydocstyle --doctest-glob="*.rst" --doctest-modules --cov=zenodo_rdm --cov-report=term-missing
59 changes: 59 additions & 0 deletions site/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 CERN.
#
# invenio-administration is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
"""Pytest fixtures."""

from collections import namedtuple

import pytest
from invenio_app.factory import create_api as _create_api


@pytest.fixture(scope="module")
def app_config(app_config):
"""Mimic an instance's configuration."""
return app_config


@pytest.fixture(scope="module")
def create_app(instance_path, entry_points):
"""Application factory fixture."""
return _create_api


RunningApp = namedtuple(
"RunningApp",
[
"app",
"location",
"cache",
],
)


@pytest.fixture
def running_app(
app,
location,
cache,
):
"""Fixture provides an app with the typically needed db data loaded.
All of these fixtures are often needed together, so collecting them
under a semantic umbrella makes sense.
"""
return RunningApp(
app,
location,
cache,
)


@pytest.fixture
def test_app(running_app):
"""Get current app."""
return running_app.app
8 changes: 8 additions & 0 deletions site/tests/support/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 CERN.
#
# invenio-administration is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
"""Pytest fixtures."""
91 changes: 91 additions & 0 deletions site/tests/support/test_contact_form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 CERN.
#
# invenio-administration is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
"""Test support contact form."""

import pytest
from marshmallow import ValidationError

from zenodo_rdm.support.support import ZenodoSupport


@pytest.fixture
def support_view():
return ZenodoSupport()


@pytest.fixture
def support_email_service(support_view):
return support_view.email_service


@pytest.fixture
def form_json_data():
return {
"name": "John Doe",
"email": "[email protected]",
"category": "file-modification",
"description": "Hi! I need some help with my record ...",
"subject": "Record file is wrong",
"sysInfo": False,
"files": [],
}


def test_endpoints():
pass


def test_form_handler(support_view):
# TODO
# support_view.handle_form()
pass


def test_form_validation_valid(form_json_data, support_view, test_app):
"""Tests form with valid data."""
validated_data = support_view.validate_form(form_json_data)
assert validated_data
assert type(validated_data) == dict
assert validated_data == form_json_data


def test_form_validation_invalid_unknown_fields(form_json_data, support_view):
"""Tests invalid form with unknown fields."""
invalid_data = {**form_json_data, "unknown": "Unknown field"}
with pytest.raises(ValidationError):
support_view.validate_form(invalid_data)


def test_form_validation_invalid_description(form_json_data, support_view, test_app):
"""Tests form with invalid description."""
min_length = test_app.config["SUPPORT_DESCRIPTION_MIN_LENGTH"]
# Small description should fail
invalid_data = {**form_json_data, "description": "a" * (min_length - 1)}
with pytest.raises(ValidationError):
support_view.validate_form(invalid_data)

max_length = test_app.config["SUPPORT_DESCRIPTION_MAX_LENGTH"]
# Large description should fail
invalid_data = {**form_json_data, "description": "a" * (max_length + 1)}
with pytest.raises(ValidationError):
support_view.validate_form(invalid_data)


def test_form_validation_invalid_categories(form_json_data, support_view):
"""Tests form with invalid category."""
# Invalid category should fail
invalid_data = {**form_json_data, "category": "invalid-category"}
with pytest.raises(ValidationError):
support_view.validate_form(invalid_data)


def test_form_validation_invalid_required_fields(form_json_data, support_view):
"""Tests form with missing required field."""
invalid_data = {**form_json_data, "name": None}
with pytest.raises(ValidationError):
support_view.validate_form(invalid_data)
1 change: 1 addition & 0 deletions site/zenodo_rdm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.0.0'
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
export default categories = [
{
'key': 'file-modification',
'title': 'File modification',
'description': (
'All requests related to updating files in already published '
'record(s). This includes new file addition, file removal or '
'file replacement. '
'Before sending a request, please consider creating a '
'<a href="http://help.zenodo.org/#versioning">new version</a> '
'of your upload. Please first consult our '
'<a href="http://help.zenodo.org/#general">FAQ</a> to get familiar'
' with the file update conditions, to see if your case is '
'eligible.<br /><br />'
'You request has to contain <u>all</u> of the points below:'
'<ol>'
'<li>Provide a justification for the file change in the '
'description.</li>'
'<li>Mention any use of the record(s) DOI in publications or '
'online, e.g.: list papers that cite your record and '
'provide links to posts on blogs and social media. '
'Otherwise, state that to the best of your knowledge the DOI has '
'not been used anywhere.</li>'
'<li>Specify the record(s) you want to update <u>by the Zenodo'
' URL</u>, e.g.: "https://zenodo.org/record/8428".<br />'
"<u>Providing only the record's title, publication date or a "
"screenshot with search result is not explicit enough</u>.</li>"
'<li>If you want to delete or update a file, specify it '
'<u>by its filename</u>, and mention if you want the name to '
'remain as is or changed (by default the filename of the new '
'file will be used).</li>'
'<li>Upload the new files below or provide a publicly-accessible '
'URL(s) with the files in the description.</li>'
'</ol>'
'<b><u>Not providing full information on any of the points above '
'will significantly slow down your request resolution</u></b>, '
'since our support staff will have to reply back with a request '
'for missing information.'
),
},
{
'key': 'upload-quota',
'title': 'File upload quota increase',
'description': (
'All requests for a quota increase beyond the 50GB limit. '
'Please include the following information with your request:'
'<ol>'
'<li>The total size of your dataset, number of files and the '
'largest file in the dataset. When referring to file sizes'
' use <a href="https://en.wikipedia.org/wiki/IEEE_1541-2002">'
'SI units</a></li>'
'<li>Information related to the organization, project or grant '
'which was involved in the research, which produced the '
'dataset.</li>'
'<li>Information on the currently in-review or future papers that '
'will cite this dataset (if applicable). If possible specify the '
'journal or conference.</li>'
'</ol>'
),
},
{
'key': 'record-inactivation',
'title': 'Record inactivation',
'description': (
'Requests related to record inactivation, either by the record '
'owner or a third party. Please specify the record(s) in question '
'by the URL(s), and reason for the inactivation.'
),
},
{
'key': 'openaire',
'title': 'OpenAIRE',
'description': (
'All questions related to OpenAIRE reporting and grants. '
'Before sending a request, make sure your problem was not '
'already resolved, see OpenAIRE '
'<a href="https://www.openaire.eu/faqs">FAQ</a>. '
'For questions unrelated to Zenodo, you should contact OpenAIRE '
'<a href="https://www.openaire.eu/support/helpdesk">'
'helpdesk</a> directly.'
),
},
{
'key': 'partnership',
'title': 'Partnership, outreach and media',
'description': (
'All questions related to possible partnerships, outreach, '
'invited talks and other official inquiries by media.'
'If you are a journal, organization or conference organizer '
'interested in using Zenodo as archive for your papers, software '
'or data, please provide details for your usecase.'
),
},
{
'key': 'tech-support',
'title': 'Security issue, bug or spam report',
'description': (
'Report a technical issue or a spam content on Zenodo.'
'Please provide details on how to reproduce the bug. '
'Upload any screenshots or files which are relevant to the issue '
'or to means of reproducing it. Include error messages and '
'error codes you might be getting in the description.<br /> '
'For REST API errors, provide a minimal code which produces the '
'issues. Use external services for scripts and long text'
', e.g.: <a href="https://gist.github.com/">GitHub Gist</a>. '
'<strong>Do not disclose your password or REST API access tokens.'
'</strong>'
),
},
{
'key': 'other',
'title': 'Other',
'description': (
'Questions which do not fit into any other category.'),
},
];
Loading

0 comments on commit 7eb327c

Please sign in to comment.