Beispiel #1
0
def edit_tags(request, production_id):
	production = get_object_or_404(Production, id=production_id)
	old_tags = set(production.tags.names())
	form = ProductionTagsForm(request.POST, instance=production)
	form.save()
	new_tags = set(production.tags.names())
	if new_tags != old_tags:
		names_string = u', '.join(production.tags.names())
		Edit.objects.create(action_type='production_edit_tags', focus=production,
			description=u"Set tags to %s" % names_string, user=request.user)

		# delete any tags that are now unused
		Tag.objects.annotate(num_prods=Count('taggit_taggeditem_items')).filter(num_prods=0).delete()
	return HttpResponseRedirect(production.get_absolute_url())
Beispiel #2
0
def edit_tags(request, production_id):
    production = get_object_or_404(Production, id=production_id)
    if not production.editable_by_user(request.user):
        raise PermissionDenied
    old_tags = set(production.tags.names())
    form = ProductionTagsForm(request.POST, instance=production)
    form.save()
    new_tags = set(production.tags.names())
    if new_tags != old_tags:
        names_string = u', '.join(production.tags.names())
        Edit.objects.create(action_type='production_edit_tags',
                            focus=production,
                            description=u"Set tags to %s" % names_string,
                            user=request.user)

        # delete any tags that are now unused
        Tag.objects.annotate(
            num_prods=Count('taggit_taggeditem_items')).filter(
                num_prods=0).delete()
    return HttpResponseRedirect(production.get_absolute_url())
Beispiel #3
0
def show(request, production_id, edit_mode=False):
	production = get_object_or_404(Production, id=production_id)
	if production.supertype != 'production':
		return HttpResponseRedirect(production.get_absolute_url())

	if request.user.is_authenticated:
		comment = Comment(commentable=production, user=request.user)
		comment_form = CommentForm(instance=comment, prefix="comment")
		tags_form = ProductionTagsForm(instance=production)
	else:
		comment_form = None
		tags_form = None

	if production.can_have_pack_members():
		pack_members = [
			link.member for link in
			production.pack_members.select_related('member').prefetch_related('member__author_nicks__releaser', 'member__author_affiliation_nicks__releaser')
		]
	else:
		pack_members = None

	try:
		meta_screenshot = random.choice(production.screenshots.exclude(standard_url=''))
	except IndexError:
		meta_screenshot = None

	return render(request, 'productions/show.html', {
		'production': production,
		'editing_credits': (request.GET.get('editing') == 'credits'),
		'credits': production.credits_for_listing(),
		'carousel': Carousel(production, request.user),

		'download_links': production.download_links,
		'external_links': production.external_links,
		'soundtracks': [
			link.soundtrack for link in
			production.soundtrack_links.order_by('position').select_related('soundtrack').prefetch_related('soundtrack__author_nicks__releaser', 'soundtrack__author_affiliation_nicks__releaser')
		],
		'competition_placings': production.competition_placings.select_related('competition__party').order_by('competition__party__start_date_date'),
		'invitation_parties': production.invitation_parties.order_by('start_date_date'),
		'release_parties': production.release_parties.order_by('start_date_date'),
		'tags': production.tags.order_by('name'),
		'blurbs': production.blurbs.all() if request.user.is_staff else None,
		'pack_members': pack_members,
		'packed_in_productions': [
			pack_member.pack for pack_member in
			production.packed_in.prefetch_related('pack__author_nicks__releaser', 'pack__author_affiliation_nicks__releaser').order_by('pack__release_date_date')
		],
		'comment_form': comment_form,
		'tags_form': tags_form,
		'meta_screenshot': meta_screenshot,
	})
Beispiel #4
0
def show(request, production_id, edit_mode=False):
    production = get_object_or_404(Production, id=production_id)
    if production.supertype != 'music':
        return HttpResponseRedirect(production.get_absolute_url())

    if request.user.is_authenticated():
        comment = Comment(commentable=production, user=request.user)
        comment_form = CommentForm(instance=comment, prefix="comment")
        tags_form = ProductionTagsForm(instance=production)
    else:
        comment_form = None
        tags_form = None

    return render(
        request, 'productions/show.html', {
            'production':
            production,
            'download_links':
            production.download_links,
            'external_links':
            production.external_links,
            'credits':
            production.credits_for_listing(),
            'featured_in_productions': [
                appearance.production
                for appearance in production.appearances_as_soundtrack.
                select_related('production', 'production__default_screenshot'
                               ).order_by('production__release_date_date')
            ],
            'packed_in_productions': [
                pack_member.pack
                for pack_member in production.packed_in.select_related(
                    'pack', 'pack__default_screenshot').order_by(
                        'pack__release_date_date')
            ],
            'competition_placings':
            production.competition_placings.order_by(
                'competition__party__start_date_date'),
            'invitation_parties':
            production.invitation_parties.order_by('start_date_date'),
            'release_parties':
            production.release_parties.order_by('start_date_date'),
            'tags':
            production.tags.order_by('name'),
            'blurbs':
            production.blurbs.all() if request.user.is_staff else None,
            'comment_form':
            comment_form,
            'tags_form':
            tags_form,
        })
Beispiel #5
0
def show(request, production_id, edit_mode=False):
    production = get_object_or_404(Production, id=production_id)
    if production.supertype != 'music':
        return HttpResponseRedirect(production.get_absolute_url())

    if request.user.is_authenticated:
        comment = Comment(commentable=production, user=request.user)
        comment_form = CommentForm(instance=comment, prefix="comment")
        tags_form = ProductionTagsForm(instance=production)

        awards_accepting_recommendations = [
            (event, event.get_recommendation_options(request.user, production))
            for event in Event.accepting_recommendations_for(production)
        ]
    else:
        comment_form = None
        tags_form = None

        awards_accepting_recommendations = [
            (event, None)
            for event in Event.accepting_recommendations_for(production)
        ]

    try:
        meta_screenshot = random.choice(production.screenshots.exclude(standard_url=''))
    except IndexError:
        meta_screenshot = None

    return render(request, 'productions/show.html', {
        'production': production,
        'prompt_to_edit': settings.SITE_IS_WRITEABLE and (request.user.is_staff or not production.locked),
        'download_links': production.download_links,
        'external_links': production.external_links,
        'info_files': production.info_files.all(),
        'credits': production.credits_for_listing(),
        'carousel': Carousel(production, request.user),
        'featured_in_productions': [
            appearance.production for appearance in
            production.appearances_as_soundtrack.prefetch_related('production__author_nicks__releaser', 'production__author_affiliation_nicks__releaser').order_by('production__release_date_date')
        ],
        'packed_in_productions': [
            pack_member.pack for pack_member in
            production.packed_in.prefetch_related('pack__author_nicks__releaser', 'pack__author_affiliation_nicks__releaser').order_by('pack__release_date_date')
        ],
        'tags': production.tags.order_by('name'),
        'blurbs': production.blurbs.all() if request.user.is_staff else None,
        'comment_form': comment_form,
        'tags_form': tags_form,
        'meta_screenshot': meta_screenshot,
        'awards_accepting_recommendations': awards_accepting_recommendations,
    })
Beispiel #6
0
    def get_context_data(self):
        if self.request.user.is_authenticated:
            comment = Comment(commentable=self.production,
                              user=self.request.user)
            comment_form = CommentForm(instance=comment, prefix="comment")
            tags_form = ProductionTagsForm(instance=self.production)

            awards_accepting_recommendations = [
                (event,
                 event.get_recommendation_options(self.request.user,
                                                  self.production))
                for event in Event.accepting_recommendations_for(
                    self.production)
            ]
        else:
            comment_form = None
            tags_form = None

            awards_accepting_recommendations = [
                (event, None) for event in Event.accepting_recommendations_for(
                    self.production)
            ]

        if self.production.can_have_pack_members():
            pack_members = [
                link.member
                for link in (self.production.pack_members.select_related(
                    'member').prefetch_related(
                        'member__author_nicks__releaser',
                        'member__author_affiliation_nicks__releaser'))
            ]
        else:
            pack_members = None

        try:
            meta_screenshot = random.choice(
                self.production.screenshots.exclude(standard_url=''))
        except IndexError:
            meta_screenshot = None

        return {
            'production':
            self.production,
            'prompt_to_edit':
            settings.SITE_IS_WRITEABLE
            and (self.request.user.is_staff or not self.production.locked),
            'download_links':
            self.production.download_links,
            'external_links':
            self.production.external_links,
            'info_files':
            self.production.info_files.all(),
            'editing_credits': (self.request.GET.get('editing') == 'credits'),
            'credits':
            self.production.credits_for_listing(),
            'carousel':
            Carousel(self.production, self.request.user),
            'tags':
            self.production.tags.order_by('name'),
            'blurbs':
            self.production.blurbs.all()
            if self.request.user.is_staff else None,
            'comment_form':
            comment_form,
            'tags_form':
            tags_form,
            'meta_screenshot':
            meta_screenshot,
            'awards_accepting_recommendations':
            awards_accepting_recommendations,
            'pack_members':
            pack_members,
        }