def update_by_id(cls, tag_id, new_name): # get the tag from the table tag = cls.get(tag_id) # update the tag info from the form tag.name = name update_db(tag) return tag
def check_update(): if not request.json or 'description' not in request.json: abort(400) data = request.json result = search_db(data) update_db(data) return result
def update_by_id(cls, post_id, title, content, tags): # get the post from the table post = cls.get(post_id) # update the post info from the form post.title = title post.content = content post.update_tags(tags) update_db(post) return post
def update_by_id(cls, user_id, first_name, last_name=None, image_url=None): # get the user from the table user = User.get(user_id) # update the user info from the form user.first_name = first_name user.last_name = last_name user.update_image(image_url) update_db(user) return user
def input_info(request): template = loader.get_template(r'get_info.html') # if this is a POST request we need to process the form data if request.method == 'POST': formData = { 'name' : request.POST.get('name',''), 'age' : request.POST.get('age',''), 'phone' : request.POST.get('phone',''), 'email' : request.POST.get('email','') } import models models.connect_db() new_user = models.User(request.POST.get('name',''), request.POST.get('age',''), request.POST.get('phone',''), request.POST.get('email','')) models.add_record(new_user) models.update_db() # if a GET (or any other method) we'll create a blank form else: formData = None context = RequestContext(request, { 'header_text':"Provide Information", 'formData' : formData }) return HttpResponse(template.render(context))
def add_document(): if not request.json or 'description' not in request.json: abort(400) data = request.json resp = update_db(data) return jsonify({'Response': resp}), 201
def update_name(self, val): self.name = val update_db(self)