from DataBase import dbmodule as db dbModule = db.Database() class Comments(object): def createPostComment(self, user_id, body, post_id): query = "insert into comments (user_id, post_id, body) values (%s,%s,'%s')" % ( user_id, post_id, body) if dbModule.insertToDB(query): return { 'status': 'success', 'response': 'post created success fully' } return {'status': 'failed', 'error': 'could not make comments'} def editComment(self, user_id, comment_id, body): query = "select user_id from comments where user_id = %s and id = %s" % ( user_id, comment_id) print(query) user = dbModule.selectStuff(query) if not user or user[0][0] != str(user_id): return { 'status': 'failed', 'error': 'this user cannot edit this comment' } query = "update comments set body = '%s' where id = '%s'" % ( body, comment_id) if dbModule.insertToDB(query): return {'status': 'success', 'response': 'comment modified'} return {'status': 'failed', 'error': 'failed to edit comment'}
import csv, sys, re from DataBase import dbmodule dbModule = dbmodule.Database() class Week(object): def __init__(self,week): self.week = week self.foods = [] def addFood(self,food): self.foods.append(food) def getWeek(self): return self.week def getFoods(self): return self.foods class Food(object): def __init__(self, meal, nutrient): self.meal = meal self.nutrient = nutrient def getMeal(self): return self.meal def getNutrient(self): return self.nutrient def load(fileName):