def stream_edit(request, stream_id, response_format='html'): "Stream edit page" user = request.user.get_profile() stream = get_object_or_404(MessageStream, pk=stream_id) if not request.user.get_profile().has_permission(stream, mode="w"): return user_denied(request, message="You don't have access to this Stream", response_format=response_format) if request.POST: if not 'cancel' in request.POST: form = MessageStreamForm(user, request.POST, instance=stream) if form.is_valid(): stream = form.save() return HttpResponseRedirect(reverse('messaging_stream_view', args=[stream.id])) else: return HttpResponseRedirect(reverse('messaging_stream_view', args=[stream.id])) else: form = MessageStreamForm(user, instance=stream) context = _get_default_context(request) context.update({'form': form, 'stream':stream}) return render_to_response('messaging/stream_edit', context, context_instance=RequestContext(request), response_format=response_format)
def stream_edit(request, stream_id, response_format='html'): "Stream edit page" user = request.user.get_profile() stream = get_object_or_404(MessageStream, pk=stream_id) if not request.user.get_profile().has_permission(stream, mode="w"): return user_denied(request, message="You don't have access to this Stream", response_format=response_format) if request.POST: if not 'cancel' in request.POST: form = MessageStreamForm(user, request.POST, instance=stream) if form.is_valid(): stream = form.save() return HttpResponseRedirect( reverse('messaging_stream_view', args=[stream.id])) else: return HttpResponseRedirect( reverse('messaging_stream_view', args=[stream.id])) else: form = MessageStreamForm(user, instance=stream) context = _get_default_context(request) context.update({'form': form, 'stream': stream}) return render_to_response('messaging/stream_edit', context, context_instance=RequestContext(request), response_format=response_format)
def stream_add(request, response_format='html'): "New message stream" user = request.user.get_profile() if request.POST: if not 'cancel' in request.POST: stream = MessageStream() form = MessageStreamForm(user, request.POST, instance=stream) if form.is_valid(): stream = form.save() stream.set_user_from_request(request) return HttpResponseRedirect(reverse('messaging')) else: return HttpResponseRedirect(reverse('messaging')) else: form = MessageStreamForm(user) context = _get_default_context(request) context.update({'form': form}) return render_to_response('messaging/stream_add', context, context_instance=RequestContext(request), response_format=response_format)