Skip to content

Commit

Permalink
[#1571] Don't allow updates on onpublished projects
Browse files Browse the repository at this point in the history
It's not possible to create project updates to projects that aren't
published. Remove the link to the update form in MyRSR's project list
and only link to the form on project pages of published projects.
  • Loading branch information
zzgvh committed Aug 4, 2015
1 parent 7ae156f commit 6da8cbe
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 103 deletions.
218 changes: 116 additions & 102 deletions akvo/templates/myrsr/my_projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,124 @@
{% load i18n bootstrap3 rsr_utils rules %}
{% block title %}{% trans "MyRSR - my projects" %}{% endblock %}
{% block myrsr_main %}
<div>
<div class="">
<div class="col-sm-6"><h3>{% trans "My projects" %}</h3></div>
{% has_perm 'rsr.add_project' user as can_add_project %}
{% if can_add_project %}
<div class="col-sm-6 text-right btnHeader"><a href="http://rsr.akvo.org/admin/rsr/project/add" class="btn btn-primary"><i class="fa fa-plus"></i> {% trans 'Add a new project' %}</a></div>
{% endif %}
</div>
{% if not organisations %}
<p class="noItem text-center col-sm-6 col-sm-offset-3">{% trans "You can't see any projects yet." %}</p>
<p class="text-center col-sm-8 col-sm-offset-2">
{% url 'my_details' as my_details_url %}
{% blocktrans %}
Go to the <a href="{{my_details_url}}">My details</a> page to request to join an organisation.
<div class="">
<div class="col-sm-6"><h3>{% trans "My projects" %}</h3></div>
{% has_perm 'rsr.add_project' user as can_add_project %}
{% if can_add_project %}
<div class="col-sm-6 text-right btnHeader"><a href="http://rsr.akvo.org/admin/rsr/project/add"
class="btn btn-primary"><i
class="fa fa-plus"></i> {% trans 'Add a new project' %}</a></div>
{% endif %}
</div>
{% if not organisations %}
<p class="noItem text-center col-sm-6 col-sm-offset-3">{% trans "You can't see any projects yet." %}</p>
<p class="text-center col-sm-8 col-sm-offset-2">
{% url 'my_details' as my_details_url %}
{% blocktrans %}
Go to the <a href="{{ my_details_url }}">My details</a> page to request to join an
organisation.
Once your request is approved, you will see the projects of this organisation on this page.
{% endblocktrans %}
</p>
{% else %}
<div class="col-sm-12">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search" {% if q_search %}value="{{q_search}}"{% endif %}>
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<i class="glyphicon glyphicon-search"></i>
</button>
</div>
</div>
</form>
{% endblocktrans %}
</p>
{% else %}
<div class="col-sm-12">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search"
{% if q_search %}value="{{ q_search }}"{% endif %}>
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<i class="glyphicon glyphicon-search"></i>
</button>
</div>
</div>
{% if page %}
<table class="table table-striped table-responsive myProjectList col-sm-12">
<thead>
<tr>
<th>{% trans "Project" %}</th><th>{% trans "Location" %}</th><th>{% trans "Status" %}</th><th>{% trans "Actions" %}</th></tr>
<tr>
</thead>
{% for project in page %}
</form>
</div>
{% if page %}
<table class="table table-striped table-responsive myProjectList col-sm-12">
<thead>
<tr>
<th>{% trans "Project" %}</th>
<th>{% trans "Location" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Actions" %}</th>
</tr>
</thead>
{% for project in page %}
{% if project.is_published %}
<tr class="isPublished">
{% else %}
<tr>
{% endif %}
<td class="media">
<a class="pull-left" href="{% url 'project-main' project.id %}">
{% img project 64 64 project.title %}
</a>

<div class="media-body">
<a href="{% url 'project-main' project.id %}">
<h4 class="media-heading">{{ project.title }}</h4>
</a>

<p class="small">{{ project.subtitle }}</p>
</div>
</td>
<td>{% bootstrap_icon "globe" %} {{ project.primary_location.country }}, {{ project.primary_location.country.continent }}</td>
<td>{{ project.show_status }}</td>
<td>
<div class="twoColumns clearfix">
<a href="{% url 'project-main' project.id %}">View</a>
{% has_perm 'rsr.change_project' user project as can_edit_project %}
{% has_perm 'rsr.change_publishingstatus' user project.publishingstatus as can_publish %}
{% if can_edit_project %}
<a href="/admin/rsr/project/{{ project.pk }}/">{% trans 'Edit' %}</a>
{% endif %}
{% if can_publish %}
<a href="/admin/rsr/publishingstatus/?project={{ project.pk }}">
{% if project.is_published %}
{% trans 'Unpublish' %}
{% else %}
{% trans 'Publish' %}
{% endif %}
</a>
{% endif %}
{% if project.is_published %}
<tr class="isPublished">
{% has_perm 'rsr.post_updates' project as can_add_update %}
<a href="{% url 'add-update' project.pk %}">{% trans 'Update' %}</a>
{% endif %}
<td class="media">
<a class="pull-left" href="{% url 'project-main' project.id %}">
{% img project 64 64 project.title %}
</a>
<div class="media-body">
<a href="{% url 'project-main' project.id %}">
<h4 class="media-heading">{{ project.title }}</h4>
</a>
<p class="small">{{ project.subtitle }}</p>
</div>
</td>
<td>{% bootstrap_icon "globe" %} {{project.primary_location.country}}, {{project.primary_location.country.continent}}</td>
<td>{{ project.show_status }}</td>
<td>
<div class="twoColumns clearfix">
<a href="{% url 'project-main' project.id %}">View</a>
{% has_perm 'rsr.change_project' user project as can_edit_project %}
{% has_perm 'rsr.change_publishingstatus' user project.publishingstatus as can_publish %}
{% if can_edit_project %}
<a href="/admin/rsr/project/{{project.pk}}/">{% trans 'Edit' %}</a>
{% endif %}
{% if can_publish %}
<a href="/admin/rsr/publishingstatus/?project={{project.pk}}">
{% if project.is_published %}
{% trans 'Unpublish' %}
{% else %}
{% trans 'Publish' %}
{% endif %}
</a>
{% endif %}
{% has_perm 'rsr.post_updates' project as can_add_update %}
<a href="{% url 'add-update' project.pk %}">{% trans 'Update' %}</a>
</div>
</td>
</tr>
{% endfor %}
</table>
<div class="">
<p>
{% blocktrans with start_index=page.start_index end_index=page.end_index paginator_count=paginator.count %}
Viewing {{start_index}} - {{end_index}} of {{paginator_count}} projects
{% endblocktrans %}
</p>
{% include 'navigation/pagination.html' %}
</div>
</div>
<div class="container">
{% else %}
{% if q %}
<p class="noItem text-center verticalPadding col-sm-6 col-sm-offset-3">
{% blocktrans %}Your search - {{q_search}} - did not match any projects.{% endblocktrans %}
</p>
{% elif organisations %}
<p class="noItem text-center col-sm-6 col-sm-offset-3">{% trans "You can't see any projects yet." %}</p>
<p class="text-center col-sm-8 col-sm-offset-2">
{% url 'my_details' as my_details_url %}
{% blocktrans %}
The organisation(s) you have joined do not have any projects yet.
Go to the <a href="{{my_details_url}}">My details</a> page to see your organisation(s).
{% endblocktrans %}
</p>
{% endif %}
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</table>
<div class="">
<p>
{% blocktrans with start_index=page.start_index end_index=page.end_index paginator_count=paginator.count %}
Viewing {{ start_index }} - {{ end_index }} of {{ paginator_count }} projects
{% endblocktrans %}
</p>
{% include 'navigation/pagination.html' %}
</div>
</div>
<div class="container">
{% else %}
{% if q %}
<p class="noItem text-center verticalPadding col-sm-6 col-sm-offset-3">
{% blocktrans %}Your search - {{ q_search }} - did not match any
projects.{% endblocktrans %}
</p>
{% elif organisations %}
<p class="noItem text-center col-sm-6 col-sm-offset-3">{% trans "You can't see any projects yet." %}</p>
<p class="text-center col-sm-8 col-sm-offset-2">
{% url 'my_details' as my_details_url %}
{% blocktrans %}
The organisation(s) you have joined do not have any projects yet.
Go to the <a href="{{ my_details_url }}">My details</a> page to see your
organisation(s).
{% endblocktrans %}
</p>
{% endif %}
{% endif %}
</div>
{% endblock %}
{% endif %}
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion akvo/templates/navigation/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h1>Akvo RSR</h1> {# Text is just a placeholder, svg from css #}

<ul class="nav navbar-nav navbar-right">
<li>
<a href="{% if project %}{% url 'add-update' project.pk %}{% else %}{% url 'my_projects' %}{% endif %}"
<a href="{% if project and project.publishingstatus.status == "published" %}{% url 'add-update' project.pk %}{% else %}{% url 'my_projects' %}{% endif %}"
class="btn btn-primary btn-xs navbar-btn addUpdateBtn">
<i class="fa fa-camera-retro"></i> {% trans 'Add an update' %}
</a>
Expand Down

0 comments on commit 6da8cbe

Please sign in to comment.