def post(self, shopping_list_id): """ Wir verwenden Namen, amount, article, Unit, Purchasing_user, retailer und shoppinglist des Proposals für die Erzeugung eines Gruppen-Objekts. Das serverseitig erzeugte Objekt ist das maßgebliche und wird auch dem Client zurückgegeben. """ adm = Administration() sl = adm.get_shopping_list_by_id(shopping_list_id) proposal = ListEntry.from_dict(api.payload) if sl is not None and proposal is not None: result = adm.create_list_entry(proposal.get_name(), proposal.get_amount(), proposal.get_article(), proposal.get_unit(), proposal.get_purchasing_user(), proposal.get_retailer(), proposal.get_shopping_list(), proposal.is_standardarticle()) if proposal.is_standardarticle(): shopping_list = adm.get_shopping_list_by_id( proposal.get_shopping_list()) group = adm.get_group_by_id(shopping_list.get_group()) adm.add_standardarticle_to_group(result, group) return result, 200 else: return 'ShoppingList unknown or payload not valid', 500
def post(self, group_id, list_entry_id): """Füge einen Standardartikel zu einer Gruppe hinzu.""" adm = Administration() grp = adm.get_group_by_id(group_id) le = adm.get_list_entry_by_id(list_entry_id) if grp is not None and le is not None: result = adm.add_standardarticle_to_group(le, grp) return result else: return "Group or ListEntry not found", 500