コード例 #1
0
 def get(self):
     """
     Gets all Retailer objects.
     """
     adm = ShoppingAdministration()
     result_find_all = adm.get_all_retailers()
     return result_find_all
コード例 #2
0
    def post(self):
        """
        Creates an specific ListEntry object.

        """
        adm = ShoppingAdministration()
        proposal = ListEntry.from_dict(api.payload)

        if proposal is not None:
            le = ListEntry()
            le.set_id(proposal.get_id())
            le.set_article(proposal.get_article())
            le.set_retailer(proposal.get_retailer())
            le.set_user(proposal.get_user())
            le.set_amount(proposal.get_amount())
            le.set_unit(proposal.get_unit())
            le.set_buy_date(proposal.get_buy_date())
            le.set_group(proposal.get_group())
            le.set_shoppinglist(proposal.get_shoppinglist())

            res = adm.insert_listentry(le)

            return res, 200
        else:
            return "", 500
コード例 #3
0
 def get(self):
     """
     Returns all User objects.
     """
     adm = ShoppingAdministration()
     result_find_all = adm.get_all_user()
     return result_find_all
コード例 #4
0
    def post(self):
        """
        creates an new specific group object or updates an exisiting group object. 
        """
        adm = ShoppingAdministration()
        try:
            print(str(api.payload))
            proposal = FavoriteArticle.from_dict(api.payload)
            if proposal is not None:
                fav = FavoriteArticle()
                fav.set_id(proposal.get_id())
                fav.set_Group_ID(proposal.get_Group_ID())
                fav.set_Article_ID(proposal.get_Article_ID())
                fav.set_amount(proposal.get_amount())
                fav.set_unit(proposal.get_unit())
                fav.set_Retailer_ID(proposal.get_Retailer_ID())
                fav.set_creationdate(proposal.get_creationdate())
                """ Upadates if proposal id != 0 """

                if (proposal.get_id() == 0):
                    c = adm.insert_FavoriteArticle(fav)

                else:
                    c = adm.update_FavoriteArticle(fav)

                return c, 200
            else:
                return "", 500

        except Exception as e:
            print(str(e))
            return str(e), 500
コード例 #5
0
    def get(self, userid):
        """
        Gets an specific Group object.

        The object is determined by the ``user_id`` in the URI.
        """
        adm = ShoppingAdministration()
        return adm.get_all_user_groups(userid)
コード例 #6
0
    def get(self, groupid):
        """
        Gets an specific membership object.

        The object is determined by the ``group_id`` in the URI.
        """
        adm = ShoppingAdministration()
        return adm.get_users_by_groupid(groupid)
コード例 #7
0
    def get(self, id):
        """
        Gets an specific user object.

        The object is determined by the ``id`` in the URI.
        """
        adm = ShoppingAdministration()
        return adm.get_user_by_id(id)
コード例 #8
0
    def get(self, name):
        """
        Gets an specific Article object.

        The object is determined by the ``name`` in the URI.
        """
        adm = ShoppingAdministration()
        return adm.get_article_by_name(name)
コード例 #9
0
    def get(self, id):
        """
        Gets an specific FavoriteArticle object.

        The object is determined by the ``id`` in the URI.
        """

        adm = ShoppingAdministration()
        return adm.get_FavoriteArticle_by_id(id)
コード例 #10
0
    def get(self):
        """
        Gets an specific ShoppingList object.

        The object is determined by the query parameter group_id.
        """
        group_id = request.args.get('group_id')
        adm = ShoppingAdministration()
        return adm.get_shoppinglists_by_group_id(group_id)
コード例 #11
0
    def get(self, email):
        """
        Gets an specific user object.

        The object is determined by the ``email`` in the URI.
        """
        adm = ShoppingAdministration()
        usr = adm.get_user_by_email(email)
        return usr
コード例 #12
0
    def get(self, name):
        """
        Gets an specific user object.

        The object is determined by the ``name`` in the URI.
        """
        adm = ShoppingAdministration()
        usr = adm.get_user_by_name(name)
        return usr
コード例 #13
0
    def get(self, firebaseid):
        """
        Gets an specific User object.

        The object is determined by the ``firebaseid`` in the URI.
        """
        adm = ShoppingAdministration()
        usr = adm.get_user_by_firebase_id(firebaseid)
        return usr
コード例 #14
0
    def get(self, id):
        """
        Gets an specific report object.

        The object is determined by the ``id`` in the URI.
        """
        adm = ShoppingAdministration()
        result = adm.get_report_entries(id)
        return result
コード例 #15
0
    def delete(self, id):
        """
        Deletes an specific FavoriteArticle object.

        The object is determined by the ``id`` in the URI.
        """
        adm = ShoppingAdministration()
        fa = adm.get_FavoriteArticle_by_id(id)
        adm.delete_FavoriteArticle(fa)
コード例 #16
0
    def get(self, key):
        """
        Gets an specific ListEntry object.

        The object is determined by the ``id`` in the URI.
        """
        adm = ShoppingAdministration()
        result = adm.find_listentry_by_key(key)
        return result
コード例 #17
0
    def delete(self, id):
        """
        Deletes an specific Article object.

        The object is determined by the ``id`` in the URI.
        """
        adm = ShoppingAdministration()
        ar = adm.get_article_by_id(id)
        adm.delete_article(ar)
        return 'deleted', 200
コード例 #18
0
    def post(self):
        """
        Creates an new membership object.
        """

        userid = api.payload["User_ID"]
        groupid = api.payload["Group_ID"]

        adm = ShoppingAdministration()
        return adm.create_membership(userid, groupid)
コード例 #19
0
    def delete(self, id):
        """
        Deletes an specific user object.

        The object is determined by the ``id`` in the URI.
        """
        adm = ShoppingAdministration()
        usr = adm.get_user_by_id(id)
        adm.delete_user(usr)
        return "deleted", 200
コード例 #20
0
    def delete(self, id):
        """
        Deletes an specific ShoppingList object.

        The object is determined by the ``id`` in the URI.
        """

        adm = ShoppingAdministration()
        slist = adm.get_shoppinglist_by_id(id)
        return adm.delete_shoppinglist(slist), 200
コード例 #21
0
    def delete(self, id):
        """
        deletes an specific ListEntry object.

        The object is determined by the ``id`` in the URI.
        """

        adm = ShoppingAdministration()
        gr = adm.get_group_by_id(id)
        adm.delete_group(gr)
コード例 #22
0
    def get(self, user):
        """
        Gets an specific ListEntry object.

        The object is determined by the ``user_id`` in the URI.
        """

        adm = ShoppingAdministration()
        result = adm.find_listentry_by_purchaser(user)
        return result
コード例 #23
0
    def delete(self):
        """
        Delete an specific Listentry 

        """
        idl = request.args.get('id')
        adm = ShoppingAdministration()
        Listentry = adm.find_listentry_by_key(idl)
        adm.delete_listentry(Listentry)
        return '', 200
コード例 #24
0
    def get(self):
        """
        Read out all the listentry objects.
        
        If no listentry objects are available, an empty sequence is returned.
        """

        adm = ShoppingAdministration()
        result = adm.get_all_listentries()
        return result
コード例 #25
0
    def get(self):
        """
        Gets an specific ListEntry object.

        The object is determined by the query parameters group_id and user_id.
        """

        user_id = request.args.get('user_id')
        group_id = request.args.get('group_id')
        adm = ShoppingAdministration()
        return adm.get_personal_items_of_group(user_id, group_id)
コード例 #26
0
    def delete(self, id):
        """
        Deletes an specific Group object.

        The object is determined by the ``id`` in the URI.
        """
        adm = ShoppingAdministration()
        grp = adm.get_group_by_id(id)

        adm.delete_group(grp)
        return "group and all memberships deleted", 200
コード例 #27
0
    def delete(self, id):
        """
        Deletes an specific Retailer object.

        The object is determined by the ``id`` in the URI.
        """

        adm = ShoppingAdministration()
        cust = adm.get_retailer_by_id(id)
        adm.delete_retailer(cust)
        return '', 200
コード例 #28
0
 def post(self):
     adm = ShoppingAdministration()
     """ try:
     """
     proposal = User.from_dict(api.payload)
     if proposal is not None:
         d = adm.insert_user(proposal)
     """ if proposal is not None:
         c = adm.create_user(proposal.get_name(),proposal.get_email(),proposal.get_firebase_id())
         return c, 200 """
     """ except Exception as e:
コード例 #29
0
    def post(self):
        """
        Creates an new shoppinglist object.
        """
        adm = ShoppingAdministration()
        proposal = ShoppingList.from_dict(api.payload)

        if proposal is not None:
            c = adm.insert_shoppinglist(proposal)
            return c, 200
        else:
            return "", 500
コード例 #30
0
    def put(self):
        """
        Update an specific shoppinglist object.
        """
        adm = ShoppingAdministration()
        proposal = ShoppingList.from_dict(api.payload)

        if proposal is not None:
            c = adm.update_shoppinglist(proposal)
            return c, 200
        else:
            return "", 500