Skip to content

Commit

Permalink
Add separate form for project visibility and improve wording
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Dec 12, 2024
1 parent d370398 commit 12798ce
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
2 changes: 2 additions & 0 deletions rdmo/core/templates/core/bootstrap_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

{% include 'core/bootstrap_form_fields.html' %}

{% if submit %}
<input type="submit" value="{{ submit }}" class="btn btn-primary" />
{% endif %}
{% if delete %}
<input type="submit" name="delete" value="{{ delete }}" class="btn btn-danger" />
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h2>{% trans 'Options' %}</h2>
<li>
<a href="{% url 'project_update_visibility' project.pk %}">
{% if not project.visibility %}
{% trans 'Make project visible to users' %}
{% trans 'Make project visible' %}
{% else %}
{% trans 'Update project visibility' %}
{% endif %}
Expand Down
17 changes: 0 additions & 17 deletions rdmo/projects/templates/projects/project_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,6 @@ <h1>{% trans 'Update project tasks' %}</h1>
<h1>{% trans 'Update project views' %}</h1>
{% bootstrap_form submit=_('Save views') %}

{% elif request.resolver_match.url_name == 'project_update_visibility' %}

<h1>{% trans 'Update project visibility' %}</h1>

<p class="mb-20">
{% blocktrans trimmed %}
Projects can be made visible to all users, for example to be used as a template.
When a project is made visible, users can access it as if they were in the guest role.
{% endblocktrans %}
</p>

{% if object.visibility %}
{% bootstrap_form submit=_('Save visibility') delete=_('Remove visibility') %}
{% else %}
{% bootstrap_form submit=_('Make visible') %}
{% endif %}

{% else %}

<h1>{% trans 'Update project information' %}</h1>
Expand Down
30 changes: 30 additions & 0 deletions rdmo/projects/templates/projects/project_form_visibility.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends 'core/page.html' %}
{% load i18n %}
{% load core_tags %}

{% block page %}

<h1>
{% if object.visibility %}
{% trans 'Update project visibility' %}
{% else %}
{% trans 'Make project visible' %}
{% endif %}
</h1>

<p class="mb-20">
{% blocktrans trimmed %}
Projects can be made visible to all users, for example to be used as a template.
When a project is made visible, users can access it as if they were in the guest role.
{% endblocktrans %}
</p>

{% if object.visibility and 'sites' in form.fields or 'groups' in form.fields %}
{% bootstrap_form submit=_('Update visibility') delete=_('Remove visibility') %}
{% elif object.visibility %}
{% bootstrap_form delete=_('Remove visibility') %}
{% else %}
{% bootstrap_form submit=_('Make visible') %}
{% endif %}

{% endblock %}
1 change: 1 addition & 0 deletions rdmo/projects/views/project_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ProjectUpdateVisibilityView(ObjectPermissionMixin, RedirectViewMixin, Upda
queryset = Project.objects.all()
form_class = ProjectUpdateVisibilityForm
permission_required = 'projects.change_visibility_object'
template_name = 'projects/project_form_visibility.html'


class ProjectUpdateCatalogView(ObjectPermissionMixin, RedirectViewMixin, UpdateView):
Expand Down

0 comments on commit 12798ce

Please sign in to comment.