예제 #1
0
파일: music.py 프로젝트: nswaldman/demozoo
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(),
		'carousel': Carousel(production, request.user),
		'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,
	})
예제 #2
0
def show(request, production_id, edit_mode=False):
    production = get_object_or_404(Production, id=production_id)
    if production.supertype != 'graphics':
        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)
        ]

    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,
        'prompt_to_edit': settings.SITE_IS_WRITEABLE and (request.user.is_staff or not production.locked),
        'credits': production.credits_for_listing(),
        'carousel': Carousel(production, request.user),
        'download_links': production.download_links,
        'external_links': production.external_links,
        'info_files': production.info_files.all(),
        '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,
        'pack_members': pack_members,
        'comment_form': comment_form,
        'tags_form': tags_form,
        'meta_screenshot': meta_screenshot,
        'awards_accepting_recommendations': awards_accepting_recommendations,
    })
예제 #3
0
def show(request, production_id, edit_mode=False):
    production = get_object_or_404(Production, id=production_id)
    if production.supertype != 'graphics':
        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

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

    return render(
        request, 'productions/show.html', {
            'production':
            production,
            'credits':
            production.credits_for_listing(),
            'carousel':
            Carousel(production, request.user),
            'download_links':
            production.download_links,
            'external_links':
            production.external_links,
            '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'),
            '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,
        })
예제 #4
0
def carousel(request, production_id):
    production = get_object_or_404(Production, id=production_id)
    carousel = Carousel(production, request.user)
    return HttpResponse(carousel.get_slides_json(), content_type='text/javascript')
예제 #5
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,
        }
예제 #6
0
def carousel(request, production_id):
    production = get_object_or_404(Production, id=production_id)
    carousel = Carousel(production, request.user)
    return HttpResponse(carousel.get_slides_json(), content_type="text/javascript")
예제 #7
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

    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.select_related(
                    'pack', 'pack__default_screenshot').order_by(
                        'pack__release_date_date')
            ],
            'comment_form':
            comment_form,
            'tags_form':
            tags_form,
        })