Skip to content

Commit

Permalink
cleanup for v1.0.3 release (#1496)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Dec 11, 2024
1 parent a61cf6c commit 0b53c66
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion docs/source/dev_resource.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------------------

Expand Down
2 changes: 1 addition & 1 deletion projectroles/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
37 changes: 13 additions & 24 deletions projectroles/views_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down Expand Up @@ -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)


Expand All @@ -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

Expand All @@ -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}
)
Expand Down

0 comments on commit 0b53c66

Please sign in to comment.