diff --git a/django_project/base/templates/project/includes/project-panel.html b/django_project/base/templates/project/includes/project-panel.html index 6b6a50961..8e9986ffd 100644 --- a/django_project/base/templates/project/includes/project-panel.html +++ b/django_project/base/templates/project/includes/project-panel.html @@ -58,32 +58,42 @@
- - Version: {{ version.name }} - - - - - - - - - -
+ {% if version.approved or user.is_authenticated %} ++ {% if version.approved %} + + Version: {{ version.name }} + + {% else %} + + Version: {{ version.name }} (pending) + + {% endif %} + + + + + + + + +
+ {% endif %} {% endfor %} {% if project.more_than_threshold %} Latest {{ project.threshold }} of {{ project.versions.count }} versionss diff --git a/django_project/base/views/project.py b/django_project/base/views/project.py index 902275477..d3c693490 100644 --- a/django_project/base/views/project.py +++ b/django_project/base/views/project.py @@ -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.""" diff --git a/django_project/changes/models/version.py b/django_project/changes/models/version.py index fb3f28e7c..a80f9ea38 100644 --- a/django_project/changes/models/version.py +++ b/django_project/changes/models/version.py @@ -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__) diff --git a/django_project/changes/views/version.py b/django_project/changes/views/version.py index c194a003e..c27c72248 100644 --- a/django_project/changes/views/version.py +++ b/django_project/changes/views/version.py @@ -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( @@ -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