From 0b53c66d4a5ccff964b7033e229867659c12c612 Mon Sep 17 00:00:00 2001 From: Mikko Nieminen Date: Wed, 11 Dec 2024 16:57:17 +0100 Subject: [PATCH] cleanup for v1.0.3 release (#1496) --- CHANGELOG.rst | 1 + docs/source/dev_resource.rst | 8 +++++++- projectroles/plugins.py | 2 +- projectroles/views_ajax.py | 37 +++++++++++++----------------------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f1f066e9..24ee278c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,7 @@ Added - **Projectroles** - Info link for finder role in ``ProjectRoleView`` (#1511) - Table and strikethrough support in ``render_markdown()`` (#1272) + - ``sodar-markdown-content`` CSS class (#1272) - **Timeline** - User count in siteinfo stats (#1504) - Plugin tests (#1506) diff --git a/docs/source/dev_resource.rst b/docs/source/dev_resource.rst index ca91a530..09dcbc07 100644 --- a/docs/source/dev_resource.rst +++ b/docs/source/dev_resource.rst @@ -145,9 +145,15 @@ documentation for more information on how to customize your widget. Markdown -------- -For fields supporting markdown, it is recommended to use the +For fields supporting Markdown, it is recommended to use the ``SODARPagedownWidget`` found in ``projectroles.models``. +.. hint:: + + When rendering Markdown fields in templates, add the + ``sodar-markdown-content`` CSS class to the field's parent container for + improved Markdown styling. + Submit Multi-Click Protection ----------------------------- diff --git a/projectroles/plugins.py b/projectroles/plugins.py index c1dba387..9c450250 100644 --- a/projectroles/plugins.py +++ b/projectroles/plugins.py @@ -772,7 +772,7 @@ def get_app_plugin(plugin_name, plugin_type=None): :param plugin_name: Plugin name (string) :param plugin_type: Plugin type (string or None for all types) - :return: Plugin object or None if not found + :return: Plugin object or None if not found or inactive """ if plugin_type: plugin_types = [PLUGIN_TYPES[plugin_type]] diff --git a/projectroles/views_ajax.py b/projectroles/views_ajax.py index 5268b393..bc50f8d5 100644 --- a/projectroles/views_ajax.py +++ b/projectroles/views_ajax.py @@ -546,12 +546,10 @@ def get_queryset(self): project_uuid = self.forwarded.get('project', None) exclude_uuids = self.forwarded.get('exclude', None) scope = self.forwarded.get('scope', 'all') + qs = User.objects.all() # If project UUID is given, only show users that are in the project - if scope in ['project', 'project_exclude'] and project_uuid not in [ - '', - None, - ]: + if scope in ['project', 'project_exclude'] and project_uuid: project = Project.objects.filter(sodar_uuid=project_uuid).first() # If user has no permission for the project, return None if not self.request.user.has_perm( @@ -560,12 +558,9 @@ def get_queryset(self): return User.objects.none() project_users = [a.user.pk for a in project.get_roles()] if scope == 'project': # Limit choices to current project users - qs = User.objects.filter(pk__in=project_users) + qs = qs.filter(pk__in=project_users) elif scope == 'project_exclude': # Exclude project users - qs = User.objects.exclude(pk__in=project_users) - # Else include all users - else: - qs = User.objects.all() + qs = qs.exclude(pk__in=project_users) # Exclude users in the system group unless local users are allowed allow_local = getattr(settings, 'PROJECTROLES_ALLOW_LOCAL_USERS', False) @@ -598,7 +593,6 @@ def get_result_value(self, user): def get(self, request, *args, **kwargs): if not request.user.is_authenticated: return HttpResponseForbidden() - return super().get(request, *args, **kwargs) @@ -610,7 +604,6 @@ class UserAutocompleteRedirectAjaxView(UserAutocompleteAjaxView): def get_create_option(self, context, q): """Form the correct email invite option to append to results""" - create_option = [] validator = EmailValidator() display_create_option = False @@ -632,22 +625,18 @@ def get_create_option(self, context, q): display_create_option = False if display_create_option: - create_option = [ - { - 'id': q, - 'text': ('Send an invite to "%(new_value)s"') - % {'new_value': q}, - 'create_id': True, - } - ] - return create_option + create_option = { + 'id': q, + 'text': 'Send an invite to "{}"'.format(q), + 'create_id': True, + } + return [create_option] + return [] - def post(self, request): - """Send the invite form url to which the forwarded values will be - send""" + def post(self, request, *args, **kwargs): + # Return JSON with redirect URL project_uuid = self.request.POST.get('project', None) project = Project.objects.filter(sodar_uuid=project_uuid).first() - # create JSON with address to redirect to redirect_url = reverse( 'projectroles:invite_create', kwargs={'project': project.sodar_uuid} )