fixed implementation of UGC content uploader

This commit is contained in:
2026-08-03 18:57:39 -05:00
parent 39e31d3980
commit 473b3c811b
40 changed files with 4137 additions and 87 deletions
+64
View File
@@ -0,0 +1,64 @@
from django import forms
from .models import Project
class ProjectForm(forms.Form):
title = forms.CharField(
max_length=128,
widget=forms.TextInput(attrs={'placeholder': 'Project title'}),
)
summary = forms.CharField(
max_length=255,
required=False,
widget=forms.TextInput(attrs={'placeholder': 'One-line summary shown on cards'}),
)
category = forms.ChoiceField(choices=Project.CATEGORY_CHOICES)
description = forms.CharField(
required=False,
widget=forms.Textarea(attrs={
'rows': 8,
'placeholder': 'Write the description in Markdown…',
}),
)
thumbnail = forms.ImageField(required=False)
caption = forms.CharField(
max_length=128,
required=False,
widget=forms.TextInput(attrs={'placeholder': 'Optional caption for the gallery media'}),
)
tags = forms.CharField(
required=False,
widget=forms.HiddenInput(),
label='',
)
class VersionForm(forms.Form):
def __init__(self, *args, required_file=True, **kwargs):
# The create flow uploads the version file out-of-band (temp upload),
# so there the `file` field is optional in the bound form.
super().__init__(*args, **kwargs)
if not required_file:
self.fields['file'].required = False
version_name = forms.CharField(
max_length=64,
label='Version',
widget=forms.TextInput(attrs={'placeholder': 'e.g. 1.0.0'}),
)
file = forms.FileField(label='File')
changelog = forms.CharField(
required=False,
widget=forms.Textarea(attrs={
'rows': 4,
'placeholder': 'What changed in this version? (Markdown)',
}),
)
class ContributorForm(forms.Form):
username = forms.CharField(
max_length=150,
widget=forms.TextInput(attrs={'placeholder': 'Start typing a username…', 'autocomplete': 'off'}),
)