Esempio n. 1
0
def create(account, team, name, content):
    assert_member(account, team)
    blog = Blog()
    blog.team = team
    blog.name = name
    blog.content = content
    blog.created_by = account
    blog.updated_by = account
    blog.save()
    return blog
Esempio n. 2
0
def blog(request):

	try:
		blog = Blog.objects.get(user=request.user)
	except Blog.DoesNotExist:
		create_blog = Blog(user=request.user)
		create_blog.save()
		blog = Blog.objects.get(user=request.user)
	except:
		blog = None

	return {'blog': blog}
Esempio n. 3
0
 def add_blog(kwargs):
     """
     新增文章
     :param kwargs:
     :return:
     """
     blog_obj = Blog(topic_id=kwargs['topic_id'],
                     content=kwargs['content'],
                     title=kwargs['title'],
                     category_id=kwargs['category_id'],
                     creator=kwargs['creator'])
     blog_obj.save()
     blog_id = blog_obj.id
     queryset_list = []
     tag_id_list = kwargs['tag_id_list']
     for tag_id in tag_id_list:
         queryset_list.append(
             BlogTag(blog_id=blog_id,
                     tag_id=tag_id,
                     creator=kwargs['creator']))
     BlogTag.objects.bulk_create(queryset_list)
     return True, ''
Esempio n. 4
0
 def mutate(root, info, input):
     blog = Blog()
     for key, val in input.items():
         setattr(blog, key, val)
     blog.save()
     return CreateBlog(ok=True, blog=blog)