Пример #1
0
	def __init__(self, *args, **kwargs):
		super(ProductionEditCoreDetailsForm, self).__init__(*args, **kwargs)
		self.fields['types'] = ProductionTypeMultipleChoiceField(required=False, label='Type',
			initial=[typ.id for typ in self.instance.types.all()],
			queryset=ProductionType.featured_types())

		self.has_multiple_types = True
Пример #2
0
	def __init__(self, *args, **kwargs):
		super(CreateGraphicsForm, self).__init__(*args, **kwargs)
		self.fields['type'] = ProductionTypeChoiceField(
			queryset=ProductionType.graphic_types(),
			initial=ProductionType.objects.get(internal_name='graphics')
		)
		self.fields['platform'] = forms.ModelChoiceField(required=False, queryset=Platform.objects.all(), empty_label='Any')
Пример #3
0
	def __init__(self, *args, **kwargs):
		super(ProductionEditCoreDetailsForm, self).__init__(*args, **kwargs)
		self.fields['types'] = ProductionTypeMultipleChoiceField(required=False, label='Type',
			initial=[typ.id for typ in self.instance.types.all()],
			queryset=ProductionType.featured_types())

		self.has_multiple_types = True
Пример #4
0
def index(request):
    queryset = Production.objects.filter(supertype='graphics')

    order = request.GET.get('order', 'date')
    asc = request.GET.get('dir', 'desc') == 'asc'

    queryset = apply_order(queryset, order, asc)

    form = GraphicsIndexFilterForm(request.GET)

    if form.is_valid():
        if form.cleaned_data['platform']:
            queryset = queryset.filter(platforms=form.cleaned_data['platform'])
        if form.cleaned_data['production_type']:
            prod_types = ProductionType.get_tree(
                form.cleaned_data['production_type'])
            queryset = queryset.filter(types__in=prod_types)

    queryset = queryset.prefetch_related('author_nicks__releaser',
                                         'author_affiliation_nicks__releaser',
                                         'platforms', 'types')

    production_page = get_page(queryset, request.GET.get('page', '1'))

    return render(
        request, 'graphics/index.html', {
            'order': order,
            'production_page': production_page,
            'menu_section': "graphics",
            'asc': asc,
            'form': form,
        })
Пример #5
0
    def get(self, request):
        queryset = Production.objects.filter(supertype=self.supertype)

        order = request.GET.get('order', 'date')
        asc = request.GET.get('dir', 'desc') == 'asc'

        queryset = apply_order(queryset, order, asc)

        form = self.filter_form_class(request.GET)

        if form.is_valid():
            if form.cleaned_data['platform']:
                queryset = queryset.filter(
                    platforms=form.cleaned_data['platform'])
            if form.cleaned_data['production_type']:
                prod_types = ProductionType.get_tree(
                    form.cleaned_data['production_type'])
                queryset = queryset.filter(types__in=prod_types)

        queryset = queryset.prefetch_related(
            'author_nicks__releaser', 'author_affiliation_nicks__releaser',
            'platforms', 'types')

        production_page = get_page(queryset, request.GET.get('page', '1'))

        return render(
            request, self.template, {
                'order': order,
                'production_page': production_page,
                'menu_section': "productions",
                'asc': asc,
                'form': form,
            })
Пример #6
0
def index(request):
    queryset = Production.objects.filter(supertype="production")

    order = request.GET.get("order", "date")
    asc = request.GET.get("dir", "desc") == "asc"

    queryset = apply_order(queryset, order, asc)

    form = ProductionIndexFilterForm(request.GET)

    if form.is_valid():
        if form.cleaned_data["platform"]:
            queryset = queryset.filter(platforms=form.cleaned_data["platform"])
        if form.cleaned_data["production_type"]:
            prod_types = ProductionType.get_tree(form.cleaned_data["production_type"])
            queryset = queryset.filter(types__in=prod_types)

    queryset = queryset.select_related("default_screenshot").prefetch_related(
        "author_nicks__releaser", "author_affiliation_nicks__releaser", "platforms", "types"
    )

    production_page = get_page(queryset, request.GET.get("page", "1"))

    return render(
        request,
        "productions/index.html",
        {"order": order, "production_page": production_page, "menu_section": "productions", "asc": asc, "form": form},
    )
Пример #7
0
 def __init__(self, *args, **kwargs):
     super(CreateGraphicsForm, self).__init__(*args, **kwargs)
     self.fields['type'] = ProductionTypeChoiceField(
         queryset=ProductionType.graphic_types(),
         initial=ProductionType.objects.get(internal_name='graphics'))
     self.fields['platform'] = forms.ModelChoiceField(
         required=False, queryset=Platform.objects.all(), empty_label='Any')
Пример #8
0
def index(request):
	queryset = Production.objects.filter(supertype='production')

	order = request.GET.get('order', 'date')
	asc = request.GET.get('dir', 'desc') == 'asc'

	queryset = apply_order(queryset, order, asc)

	form = ProductionIndexFilterForm(request.GET)

	if form.is_valid():
		if form.cleaned_data['platform']:
			queryset = queryset.filter(platforms=form.cleaned_data['platform'])
		if form.cleaned_data['production_type']:
			prod_types = ProductionType.get_tree(form.cleaned_data['production_type'])
			queryset = queryset.filter(types__in=prod_types)

	queryset = queryset.select_related('default_screenshot').prefetch_related('author_nicks__releaser', 'author_affiliation_nicks__releaser', 'platforms', 'types')

	production_page = get_page(
		queryset,
		request.GET.get('page', '1'))

	return render(request, 'productions/index.html', {
		'order': order,
		'production_page': production_page,
		'menu_section': "productions",
		'asc': asc,
		'form': form,
	})
Пример #9
0
class MusicIndexFilterForm(forms.Form):
    platform = forms.ModelChoiceField(required=False,
                                      queryset=Platform.objects.all(),
                                      empty_label='All platforms')
    production_type = ProductionTypeChoiceField(
        required=False,
        queryset=ProductionType.music_types(),
        empty_label='All types')
Пример #10
0
	def __init__(self, *args, **kwargs):
		self.instance = kwargs.pop('instance', Production())
		super(CreateProductionForm, self).__init__(*args, **kwargs)
		self.fields['title'] = forms.CharField()
		self.fields['byline'] = BylineField(required=False, label='By')
		self.fields['release_date'] = FuzzyDateField(required=False,
			help_text='(As accurately as you know it - e.g. "1996", "Mar 2010")')
		self.fields['types'] = ProductionTypeMultipleChoiceField(required=False, label='Type',
			queryset=ProductionType.featured_types())
		self.fields['platforms'] = forms.ModelMultipleChoiceField(required=False, label='Platform',
			queryset=Platform.objects.all())
Пример #11
0
	def __init__(self, *args, **kwargs):
		self.instance = kwargs.pop('instance', Production())
		super(CreateProductionForm, self).__init__(*args, **kwargs)
		self.fields['title'] = forms.CharField()
		self.fields['byline'] = BylineField(required=False, label='By')
		self.fields['release_date'] = FuzzyDateField(required=False,
			help_text='(As accurately as you know it - e.g. "1996", "Mar 2010")')
		self.fields['types'] = ProductionTypeMultipleChoiceField(required=False, label='Type',
			queryset=ProductionType.featured_types())
		self.fields['platforms'] = forms.ModelMultipleChoiceField(required=False, label='Platform',
			queryset=Platform.objects.all())
Пример #12
0
    def __init__(self, *args, **kwargs):
        super(GraphicsEditCoreDetailsForm, self).__init__(*args, **kwargs)

        self.has_multiple_types = False

        try:
            initial_type = self.instance.types.all()[0].id
        except IndexError:
            initial_type = None

        self.fields['type'] = ProductionTypeChoiceField(
            queryset=ProductionType.graphic_types(), initial=initial_type)
Пример #13
0
	def setUp(self):
		game = ProductionType.add_root(name='Game')
		stevie_dotman = Production.objects.create(
			title="Stevie Dotman", supertype="production",
			release_date_date='2000-03-18', release_date_precision='d'
		)
		stevie_dotman.types.add(game)

		Production.objects.create(
			title="Mystery Prod", supertype="production",
			release_date_date='2000-03-18', release_date_precision='d'
		)
Пример #14
0
	def __init__(self, *args, **kwargs):
		super(GraphicsEditCoreDetailsForm, self).__init__(*args, **kwargs)

		self.has_multiple_types = False

		try:
			initial_type = self.instance.types.all()[0].id
		except IndexError:
			initial_type = None

		self.fields['type'] = ProductionTypeChoiceField(
			queryset=ProductionType.graphic_types(),
			initial=initial_type
		)
Пример #15
0
	def __init__(self, *args, **kwargs):
		super(MusicIndexFilterForm, self).__init__(*args, **kwargs)
		self.fields['production_type'].queryset = ProductionType.music_types()
Пример #16
0
 def test_graphic_types(self):
     ProductionType.objects.filter(internal_name='graphics').delete()
     self.assertEqual(ProductionType.graphic_types().count(), 0)
Пример #17
0
 def __init__(self, *args, **kwargs):
     super(MusicIndexFilterForm, self).__init__(*args, **kwargs)
     self.fields['production_type'].queryset = ProductionType.music_types()