def project_version_detail(request, project_slug, version_slug): """Project version detail page.""" project = get_object_or_404( Project.objects.for_admin_user(request.user), slug=project_slug) version = get_object_or_404( Version.objects.public( user=request.user, project=project, only_active=False), slug=version_slug) form = VersionForm(request.POST or None, instance=version) if request.method == 'POST' and form.is_valid(): version = form.save() if form.has_changed(): if 'active' in form.changed_data and version.active is False: log.info('Removing files for version %s', version.slug) broadcast( type='app', task=tasks.clear_artifacts, args=[version.get_artifact_paths()]) version.built = False version.save() url = reverse('project_version_list', args=[project.slug]) return HttpResponseRedirect(url) return render( request, 'projects/project_version_detail.html', {'form': form, 'project': project, 'version': version})
def project_version_detail(request, project_slug, version_slug): """Project version detail page""" project = get_object_or_404(Project.objects.for_admin_user(request.user), slug=project_slug) version = get_object_or_404(Version.objects.public(user=request.user, project=project, only_active=False), slug=version_slug) form = VersionForm(request.POST or None, instance=version) if request.method == 'POST' and form.is_valid(): version = form.save() if form.has_changed(): if 'active' in form.changed_data and version.active is False: log.info('Removing files for version %s' % version.slug) clear_artifacts.delay(version_pk=version.pk) version.built = False version.save() url = reverse('project_version_list', args=[project.slug]) return HttpResponseRedirect(url) return render_to_response('projects/project_version_detail.html', { 'form': form, 'project': project, 'version': version }, context_instance=RequestContext(request))
def project_version_detail(request, project_slug, version_slug): """Project version detail page""" project = get_object_or_404(Project.objects.for_admin_user(request.user), slug=project_slug) version = get_object_or_404( Version.objects.public(user=request.user, project=project, only_active=False), slug=version_slug) form = VersionForm(request.POST or None, instance=version) if request.method == 'POST' and form.is_valid(): version = form.save() if form.has_changed(): if 'active' in form.changed_data and version.active is False: log.info('Removing files for version %s' % version.slug) clear_artifacts.delay(version_pk=version.pk) version.built = False version.save() url = reverse('project_version_list', args=[project.slug]) return HttpResponseRedirect(url) return render_to_response( 'projects/project_version_detail.html', {'form': form, 'project': project, 'version': version}, context_instance=RequestContext(request) )
def test_can_update_privacy_level(self): version = get( Version, project=self.project, privacy_level=PUBLIC, active=True, ) form = VersionForm( { 'active': True, 'privacy_level': PRIVATE, }, instance=version, ) self.assertTrue(form.is_valid()) self.assertEqual(version.privacy_level, PRIVATE)
def test_default_version_is_active(self): version = get( Version, project=self.project, active=False, ) self.project.default_version = version.slug self.project.save() form = VersionForm( { 'active': True, }, instance=version, ) self.assertTrue(form.is_valid())
def test_default_version_is_active(self): version = get( Version, project=self.project, active=False, ) self.project.default_version = version.slug self.project.save() form = VersionForm( { 'active': True, 'privacy_level': PRIVATE, }, instance=version, ) self.assertTrue(form.is_valid())
def test_default_version_is_inactive(self): version = get( Version, project=self.project, active=True, ) self.project.default_version = version.slug self.project.save() form = VersionForm( { 'active': False, }, instance=version, ) self.assertFalse(form.is_valid()) self.assertIn('active', form.errors)
def project_version_detail(request, project_slug, version_slug): project = get_object_or_404(Project.objects.for_admin_user(request.user), slug=project_slug) version = get_object_or_404( Version.objects.public(user=request.user, project=project, only_active=False), slug=version_slug ) form = VersionForm(request.POST or None, instance=version) if request.method == "POST" and form.is_valid(): form.save() url = reverse("project_version_list", args=[project.slug]) return HttpResponseRedirect(url) return render_to_response( "projects/project_version_detail.html", {"form": form, "project": project, "version": version}, context_instance=RequestContext(request), )
def project_version_detail(request, project_slug, version_slug): project = get_object_or_404(Project.objects.for_admin_user(request.user), slug=project_slug) version = get_object_or_404( Version.objects.public(user=request.user, project=project, only_active=False), slug=version_slug) form = VersionForm(request.POST or None, instance=version) if request.method == 'POST' and form.is_valid(): form.save() url = reverse('project_version_list', args=[project.slug]) return HttpResponseRedirect(url) return render_to_response( 'projects/project_version_detail.html', {'form': form, 'project': project, 'version': version}, context_instance=RequestContext(request) )
def project_version_detail(request, project_slug, version_slug): """Project version detail page""" project = get_object_or_404(Project.objects.for_admin_user(request.user), slug=project_slug) version = get_object_or_404( Version.objects.public(user=request.user, project=project, only_active=False), slug=version_slug) form = VersionForm(request.POST or None, instance=version) if request.method == 'POST' and form.is_valid(): form.save() url = reverse('project_version_list', args=[project.slug]) return HttpResponseRedirect(url) return render_to_response( 'projects/project_version_detail.html', {'form': form, 'project': project, 'version': version}, context_instance=RequestContext(request) )