def series_new(request): """ A logged in user can create a series. Series serve as a linking mechanism to connect related stories and to share assets between them. Series allow users to create planning notes at a series level have planning discussions and upload assets. Assets are always associated with a series so they are easily accessible to stories and all facets. This means that even single stories technically have a series, but in that case the user does not interact with any series interface. """ seriesform = SeriesForm(request=request) if request.method == "POST": seriesform = SeriesForm(request.POST, request=request) if seriesform.is_valid(): series = seriesform.save(commit=False) series.owner = request.user series.organization = request.user.organization series.creation_date = timezone.now() discussion = Discussion.objects.create_discussion("SER") series.discussion = discussion series.save() seriesform.save_m2m() # record action for activity stream action.send(request.user, verb="created", action_object=series) return redirect('series_detail', pk=series.pk) else: seriesform = SeriesForm(request=request) return render(request, 'editorial/seriesnew.html', {'seriesform': seriesform})
def series_edit(request, pk): """ Edit series page.""" series = get_object_or_404(Series, pk=pk) if request.method =="POST": seriesform = SeriesForm(data=request.POST, instance=series) if seriesform.is_valid(): seriesform.save() return redirect('series_detail', pk=series.id) else: seriesform = SeriesForm(instance=series) return render(request, 'editorial/seriesedit.html', { 'series': series, 'seriesform': seriesform, })
def series_edit(request, pk): """ Edit series page.""" series = get_object_or_404(Series, pk=pk) if request.method =="POST": seriesform = SeriesForm(data=request.POST, instance=series, request=request) if seriesform.is_valid(): seriesform.save() # record action for activity stream action.send(request.user, verb="edited", action_object=series) return redirect('series_detail', pk=series.id) else: seriesform = SeriesForm(instance=series, request=request) return render(request, 'editorial/seriesedit.html', { 'series': series, 'seriesform': seriesform, })