Esempio n. 1
0
 def DELETE(self, id):
     legal_ids = getAuthorizedHouseholdIds()
     receipt = findReceiptById(id)
     if receipt.member.household_id in legal_ids:
         delete(receipt)
     else:
         raise cherrypy.HTTPError(401, 'Unauthorized')
Esempio n. 2
0
 def POST(self, name, household_id):
     legal_ids = getAuthorizedHouseholdIds()
     if int(household_id) in legal_ids:
         member = Member(name=name, household_id=int(household_id))
         add(member)
     else:
         raise cherrypy.HTTPError(401, 'Unauthorized')
Esempio n. 3
0
 def DELETE(self, id):
     legal_ids = getAuthorizedHouseholdIds()
     member = findMemberById(id)
     h_id = member.household_id
     if h_id in legal_ids:
         delete(member)
     else:
         raise cherrypy.HTTPError(401, 'Unauthorized')
Esempio n. 4
0
 def PUT(self, id, name):
     legal_ids = getAuthorizedHouseholdIds()
     member = findMemberById(id)
     h_id = member.household.id
     if h_id in legal_ids:
         member.name = name
     else:
         raise cherrypy.HTTPError(401, 'Unauthorized')
Esempio n. 5
0
 def PUT(self, id, name):
     user = authorize()
     legal_ids = getAuthorizedHouseholdIds()
     print("DEBUG: " + str(legal_ids))
     if int(id) in legal_ids:
         household = findHouseholdById(id)
         household.name = name
     else:
         raise cherrypy.HTTPError(401,  'Unaouthorized')
Esempio n. 6
0
 def PUT(self, id, date, amount):
     legal_ids = getAuthorizedHouseholdIds()
     receipt = findReceiptById(id)
     if receipt.member.household_id in legal_ids:
         p_date = datetime.strptime(date, '%Y-%m-%d')
         receipt.date = p_date
         receipt.amount = amount
     else:
         raise cherrypy.HTTPError(401, 'Unauthorized')
Esempio n. 7
0
 def POST(self, amount, r_date, member_id):
     legal_ids = getAuthorizedHouseholdIds()
     member = findMemberById(member_id)
     if member.household.id in legal_ids:
         p_date = datetime.strptime(r_date, '%Y-%m-%d')
         receipt = Receipt(member_id=member_id, date=p_date, amount=amount)
         add(receipt)
     else:
         raise cherrypy.HTTPError(401, 'Unauthorized')
Esempio n. 8
0
 def GET(self, id=None, household_id=None):
     legal_ids = getAuthorizedHouseholdIds()
     if id is None and household_id is None:
         members = findMembersByHouseholdIds(legal_ids)
         return str(members)
     elif id is None and int(household_id) in legal_ids:
         members = findMembersByHouseholdId(household_id)
         return str(members)
     else:
         member = findMemberById(id)
         h_id = member.household.id
         if h_id in legal_ids:
             return str(member)
         else:
             raise cherrypy.HTTPError(401, 'Unauthorized')
Esempio n. 9
0
 def GET(self, receipt_id=None, member_id=None, household_id=None):
     legal_ids = getAuthorizedHouseholdIds()
     if receipt_id is None and member_id is None and household_id is None:
         receipts = findReceiptsByHouseholdIds(legal_ids)
         return str(receipts)
     elif household_id is not None and int(household_id) in legal_ids:
         receipts = findReceiptsByHouseholdId(household_id)
         return str(receipts)
     elif member_id is not None:
         member = findMemberById(member_id)
         if member.household_id in legal_ids:
             return str(member.receipts)
         else:
             raise cherrypy.HTTPException(401, 'Unauthorized')
     else:
         receipt = findReceiptById(receipt_id)
         if receipt.member.household_id in legal_ids:
             return str(receipt)
         else:
             raise cherrypy.HTTPException(401, 'Unauthorized')
Esempio n. 10
0
 def DELETE(self, id):
     user = authorize()
     legal_ids = getAuthorizedHouseholdIds()
     if int(id) in legal_ids:
         household = findHouseholdById(id)
         delete(household)