New ExportProvider and ImportProvider#1
Conversation
…also work with github apps
… method to temporarily replace rdmo.services.providers.OauthProviderMixin class
…export choices with file path validator
…ile path checking before exporting
…choicefield for oauth app
|
In the context of our MAUS project we forked this repository and develop further plugins for GitHub. Export ProviderThis provider plugin enables users to export project data to new or existing repositories on GitHub. Project data is generated with RDMO's file export plugins (XML, CSV and JSON) for all projects. SMP projects have some additional export choices that are provided by our rdmo-plugins-maus. Currently, these choices are: a README.md, a CITATION.cff, a LICENSE, and an SMP report (a document containing all the project content in the form of a report). These SMP-specific export choices are created with views that use attributes of the SMP catalog. Our hope is that, in the process of standardizing the RDMO attributes, the SMP-specific views will create usable files for every other catalog, not only SMP. Import ProviderThis provider plugin enables users to import project data from public or private GitHub repositories. Similar to the existing GitHubImport class, the new plugin enables the import of RDMO XML project files. This new plugin also allows users to import repository metadata (license, languages, dependency graph, and CITATION.cff). The metadata import is optimized for SMP projects because other catalogs may not have matching questions (and attributes) for the metadata or use different attributes. In those cases, the plugin only imports the usable subset of repository metadata. SMP CatalogAll the changes use a new version of the SMP catalog. Here is our forked repository rdmo-catalog with the modified SMP catalog as well as the new views for the export choices. Other changes1. Radio Select displaying the most recently updated, accessible GitHub repositories for each userThe existing plugins have been modified so that their form displays an overview of repositories to choose from (instead of an input field to write the repository url). This overview is filtered by the rights needed for the selected action (import or export). For example, when using the import plugin, the user only sees the repositories for which they have read access. The repository list for the export plugin may vary, because it lists those repositories for which the user has write access. 2. Modification to class IntegrationCreateViewIn order to include the list of accessible repositories for each user in the GitHubIssueProvider class of this repository, we had to modify the RDMO class IntegrationCreateView. This involved adding a setup method that checks if the integration provider has a method called integration_setup and runs it. Here is our modified code. 3. Import and export choices form fieldBoth the import and export provider plugins use a custom multiple-choice field provided by our rdmo-plugins-maus. Checkout the repository's README.md for more info. |
|
|
||
| {% bootstrap_form submit=_('Export to GitHub') %} | ||
|
|
||
| <style> |
There was a problem hiding this comment.
This should move to the head block.
|
|
||
| {{ block.super }} | ||
|
|
||
| <style> |
There was a problem hiding this comment.
This should move to the head block.
There was a problem hiding this comment.
This should just be named validadors.py and directly to rdmo_github. Same with forms.py.
| base64_bytes_of_content = base64.b64encode(binary) | ||
| base64_string_of_content = base64_bytes_of_content.decode('utf-8') | ||
| choice_content = base64_string_of_content | ||
| except: |
There was a problem hiding this comment.
Genereally, except should not be used without a specific exception to catch. Here it would be better to use
if not response.content:
...anyway.
|
|
||
| exports = form_data['exports'] | ||
| processed_exports = [] | ||
| for e in exports: |
|
|
||
| try: | ||
| response.raise_for_status() | ||
| except Exception as e: |
There was a problem hiding this comment.
To generic, for requests you can use:
try:
response.raise_for_status()
except requests.exceptions.HTTPError as e:
...| new_values = [v for v in xml_import_plugin.values if v.attribute] | ||
| xml_import_plugin.values = new_values | ||
|
|
||
| author_attribute_uris = [ |
There was a problem hiding this comment.
Static lists like this could go to the top of the class, maybe this could be separated into a maus and non-maus part.
|
We can check the settings for the plugin like this: # in apps.py
from django.apps import AppConfig
class RDMOGitHubConfig(AppConfig):
name = 'rdmo_github'
def ready(self):
import rdmo_github.checks # noqa: F401
# in checks.py
from django.conf import settings
from django.core.checks import Error, register
@register()
def check_github_provider_settings(app_configs, **kwargs):
errors = []
try:
provider = settings.GITHUB_PROVIDER
except AttributeError:
errors.append(
Error('settings.GITHUB_PROVIDER does not exist.', hint='Add GITHUB_PROVIDER to config/settings/local.py')
)
else:
for key in ['client_id', 'client_secret', 'app_type', 'github_app_name']:
if not provider.get(key):
errors.append(Error(f'Key "{key}" is missing from settings.GITHUB_PROVIDER')
)
return errors |
|
For the setup and automatic formatting, you can use the files in
should then run the hooks. If the |
…et_questionsets() and get_pages()
… parameters in the script tag in the forms' Media classes
…edia classes to define starting style of the form templates
…ing parameters from template context, and include code to append more repos in form's repo radio buttons
…ing parameters from template context, and include code to 1. append more repos in form's repo radio buttons and 2. cover xml file import for projects without the smp catalogue
No description provided.