Skip to content

Commit

Permalink
fixing bug on pending version acceptance (#359)
Browse files Browse the repository at this point in the history
* fixing bug on pending version acceptance

* fixing indent
  • Loading branch information
meomancer authored and timlinux committed Jul 21, 2016
1 parent a9099a5 commit 451cb18
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 27 deletions.
54 changes: 32 additions & 22 deletions django_project/base/templates/project/includes/project-panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,42 @@ <h3 class="panel-title">
{% endif %}
<h4 class="text-muted">
Latest Versions
<a href="{% url 'version-create' project_slug=project.slug %}"
class="btn btn-default pull-right btn-sm tooltip-toggle"
data-title="Create New Version">
{% show_button_icon "add" %}
</a>
{% if project.approved %}
<a href="{% url 'version-create' project_slug=project.slug %}"
class="btn btn-default pull-right btn-sm tooltip-toggle"
data-title="Create New Version">
{% show_button_icon "add" %}
</a>
{% endif %}
</h4>
<hr/>
{% if project.versions %}
{% for version in project.latest_versions %}
<p>
<a href="{% url "version-detail" project_slug=version.project.slug slug=version.slug %}">
<strong><span class="text-muted">Version:</span> {{ version.name }}</strong>
</a>
<span class="btn-group pull-right">
<a href="{% url "version-detail" project_slug=version.project.slug slug=version.slug %}"
class="btn btn-default btn-xs tooltip-toggle"
data-placement="top" data-title="Changelog List">
<span class="glyphicon glyphicon-list"></span>
</a>
<a href="{% url "version-thumbs" project_slug=version.project.slug slug=version.slug %}"
class="btn btn-default btn-xs tooltip-toggle"
data-placement="top" data-title="Changelog Thumbs">
<span class="glyphicon glyphicon-th"></span>
</a>
</span>
</p>
{% if version.approved or user.is_authenticated %}
<p>
{% if version.approved %}
<a href="{% url "version-detail" project_slug=version.project.slug slug=version.slug %}">
<strong><span class="text-muted">Version:</span> {{ version.name }}</strong>
</a>
{% else %}
<a href="{% url "pending-version-list" version.project.slug%}">
<strong><span class="text-muted">Version:</span> {{ version.name }}</strong> <b class="text-muted">(pending)</b>
</a>
{% endif %}
<span class="btn-group pull-right">
<a href="{% url "version-detail" project_slug=version.project.slug slug=version.slug %}"
class="btn btn-default btn-xs tooltip-toggle"
data-placement="top" data-title="Changelog List">
<span class="glyphicon glyphicon-list"></span>
</a>
<a href="{% url "version-thumbs" project_slug=version.project.slug slug=version.slug %}"
class="btn btn-default btn-xs tooltip-toggle"
data-placement="top" data-title="Changelog Thumbs">
<span class="glyphicon glyphicon-th"></span>
</a>
</span>
</p>
{% endif %}
{% endfor %}
{% if project.more_than_threshold %}
<strong><span class="text-muted">Latest {{ project.threshold }} of {{ project.versions.count }} versionss</span></strong>
Expand Down
5 changes: 4 additions & 1 deletion django_project/base/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ def get_queryset(self):
return qs.filter(owner=self.request.user)

def get_success_url(self):
return reverse('project-detail', kwargs={'slug': self.object.slug})
if self.object.approved:
return reverse('project-detail', kwargs={'slug': self.object.slug})
else:
return reverse('pending-project-list')

def form_valid(self, form):
"""Check that there is no referential integrity error when saving."""
Expand Down
6 changes: 3 additions & 3 deletions django_project/changes/models/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from common.utilities import version_slugify
import os
import logging
from core.settings.contrib import STOP_WORDS
from django.conf.global_settings import MEDIA_ROOT
from django.db import models
from .entry import Entry
from .sponsorship_period import SponsorshipPeriod
from core.settings.contrib import STOP_WORDS
from django.conf.global_settings import MEDIA_ROOT
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from django.db import models

logger = logging.getLogger(__name__)

Expand Down
10 changes: 9 additions & 1 deletion django_project/changes/views/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ def get_object(self, queryset=None):
'Requested project does not exist.')
try:
obj = queryset.filter(project=project).get(slug=slug)
if not obj.approved:
raise Http404(
'Sorry! The project you are requesting a version for '
'could not be found or you do not have permission to '
'view the version. Also the version may not be '
'approved yet. Try logging in as a staff member if '
'you wish to view it.')
return obj
except Version.DoesNotExist:
raise Http404(
Expand Down Expand Up @@ -539,7 +546,8 @@ def get_redirect_url(self, project_slug, slug):
:returns: A url.
:rtype: str
"""
project = Project.objects.get(slug=project_slug)
project = Project.objects.filter(slug=project_slug)
project = get_object_or_404(project, approved=True)
version_qs = Version.unapproved_objects.filter(project=project)
version = get_object_or_404(version_qs, slug=slug)
version.approved = True
Expand Down

0 comments on commit 451cb18

Please sign in to comment.