Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing bug on pending version acceptance #359

Merged
merged 2 commits into from
Jul 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -141,6 +141,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 @@ -515,7 +522,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