(wip) episode_form: add inline track formset
This commit is contained in:
parent
07075d3b90
commit
9378435345
|
@ -20,7 +20,11 @@
|
|||
{% render_honeypot_field "website" %}
|
||||
</table>
|
||||
<br/>
|
||||
{{ forms }}
|
||||
<br/>
|
||||
<input type="submit" value="Update" class="button is-success">
|
||||
</form>
|
||||
|
||||
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
from django.contrib.auth.mixins import UserPassesTestMixin
|
||||
from django.forms import ModelForm, FileField
|
||||
from django.forms.models import modelformset_factory
|
||||
from django.urls import reverse
|
||||
|
||||
from ckeditor.fields import RichTextField
|
||||
from filer.models.filemodels import File
|
||||
|
||||
from aircox.controllers.sound_file import SoundFile
|
||||
from aircox.models import Track
|
||||
|
||||
from ..filters import EpisodeFilters
|
||||
from ..models import Episode, Program, StaticPage
|
||||
|
@ -82,3 +84,12 @@ class EpisodeUpdateView(UserPassesTestMixin, BaseProgramMixin, PageUpdateView):
|
|||
|
||||
def get_success_url(self):
|
||||
return reverse("episode-detail", kwargs={"slug": self.get_object().slug})
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
formset = modelformset_factory(Track, fields=["title", "artist"])
|
||||
context["forms"] = formset(queryset=Track.objects.filter(episode=self.object))
|
||||
return context
|
||||
|
||||
# def post(self, request, *args, **kwargs):
|
||||
# def form_valid(self, formset,day_form):
|
||||
|
|
Loading…
Reference in New Issue
Block a user