def create_user_blog(strategy, *args, **kwargs): """ creates a blog for new users. This doesn't give them any permissions to post, however. """ logger.debug("%s.create_user_blog entered" % __name__) if not kwargs['is_new']: logger.info('Existing user, returning') return user = kwargs['user'] if user.author.fullname == '': fullname = "Some guy" else: fullname = user.author.fullname site = Site.objects.get(pk=settings.SITE_ID) struct = { 'title': "%s's Space" % fullname, 'description': 'Thoughts, articles, notes', 'site': site, 'owner': user } logger.info("Creating blog for '%s'" % user) blog = Blog(**struct) logger.debug("created %s" % str(blog)) blog.save()
def edit(request): if request.method == 'POST': form = BlogForm(request.POST) if form.is_valid(): caption = form.clean_data['caption'] article_id = form.clean_data['article_id'] category = form.clean_data['category'] content = form.clean_data['content'] blog = Blog(caption=caption, article_id=article_id, category=category, content=content) blog.save() return HttpResponseRedirect("/bloglist/") else: form = BlogForm() return render_to_response('edit.html', {'form': form}, context_instance=RequestContext(request))