def update_info(request, update_id): if request.method == "POST": if not request.user.is_authenticated(): return HttpResponse("error: must be logged in to edit") try: update = Update.objects.get(id=update_id) if (not request.user.is_staff) and update.author != request.user: return HttpResponse("error: no edit permissions, must be author or staff") except: update = Update(type="blog", author=request.user) update.title = request.POST.get("title") update.content = request.POST.get("content") project_id = request.POST.get("project", "") if project_id: try: if update.project: update.project.remove_update(update) project = Project.objects.get(id=project_id) update.project = project update.type="dev log" except: update.project = None update.save() if request.FILES.get("thumbnail"): if not update.thumbnail: thumbnail = Image() else: thumbnail = update.thumbnail thumbnail.data = request.FILES.get("thumbnail") thumbnail.save() update.thumbnail = thumbnail update.save() logging.info("$$$ saved update thumbnail: %s" % update.thumbnail.id) else: logging.info("$$$ no request.FILES.get('thumbnail') :(") for f in request.FILES: logging.info("$$$$$ %s" % f) logging.info("$$$ saved update: %s" % update.id) return HttpResponseRedirect("/blurb/%s/" % update.id) update = get_object_or_404(Update, id=update_id) if update.type == "new project" or update.type == "pitch": # updates about a new project don't have their own content, # but rather link straight to the project in question return HttpResponseRedirect("/project/%s/" % update.project.id) is_edit = request.GET.get("edit") if request.is_ajax(): if is_edit: return render_to_response("new_blog.html", locals(), context_instance=RequestContext(request)) return render_to_response("update.html", locals()) else: url = '/blurb/%s/' % update_id if is_edit: url = "%s?edit=t" % url request.session['info_ajax_url'] = url return HttpResponseRedirect("/")