コード例 #1
0
ファイル: country.py プロジェクト: gcandal/budy
    def simple_csv(self):
        object = appier.get_object(
            alias = True,
            find = True,
            limit = 0
        )
        countries = budy.Country.find(**object)

        countries_s = [(
            "name",
            "country_code",
            "currency_code",
            "locale"
        )]
        for country in countries:
            country_s = (
                country.name,
                country.country_code,
                country.currency_code,
                country.locale
            )
            countries_s.append(country_s)

        result = appier.serialize_csv(countries_s, delimiter = ",")
        self.content_type("text/csv")
        return result
コード例 #2
0
ファイル: account.py プロジェクト: gcandal/budy
    def simple_csv(self):
        object = appier.get_object(
            alias = True,
            find = True,
            limit = 0
        )
        accounts = budy.BudyAccount.find(
            **object
        )

        accounts_s = [(
            "username",
            "email",
            "first_name",
            "last_name",
            "birth_date"
        )]
        for account in accounts:
            account_s = (
                account.username,
                account.email,
                account.first_name,
                account.last_name,
                account.birth_date
            )
            accounts_s.append(account_s)

        result = appier.serialize_csv(accounts_s, delimiter = ",")
        self.content_type("text/csv")
        return result
コード例 #3
0
ファイル: part.py プロジェクト: hivesolutions/appier_extras
 def model_json(self, model):
     model_c = self.owner.get_model(model)
     object = appier.get_object(alias=True, find=True, limit=0)
     models = self.owner.admin_part._find_view(model_c,
                                               map=True,
                                               rules=False,
                                               **object)
     return models
コード例 #4
0
 def list_json(self):
     object = appier.get_object(
         alias = True,
         find = True,
         sort = [("created", -1)]
     )
     provisions = digitalriver.Provision.find(map = True, **object)
     return provisions
コード例 #5
0
ファイル: part.py プロジェクト: hivesolutions/appier_extras
 def model_import_api(self, model):
     object = appier.get_object()
     model_c = self.owner.get_model(model)
     items = object.get("items", [])
     for model_d in items:
         if "_id" in model_d: del model_d["_id"]
         model = model_c(model_d)
         model.save(validate=False, verify=False)
コード例 #6
0
ファイル: product.py プロジェクト: gcandal/budy
 def list(self):
     object = appier.get_object(alias = True, find = True)
     products = budy.Product.find(
         find_t = "right",
         eager = ("images", "brand"),
         map = True,
         **object
     )
     return products
コード例 #7
0
 def search(self):
     object = appier.get_object(
         alias = True,
         find = True,
         find_i = True,
         find_t = "right"
     )
     indexes = models.Search.find(map = True, **object)
     return indexes
コード例 #8
0
ファイル: currency.py プロジェクト: gcandal/budy
 def list(self):
     object = appier.get_object(alias = True, find = True)
     currencies = budy.Currency.find(
         find_i = True,
         find_t = "right",
         map = True,
         **object
     )
     return currencies
コード例 #9
0
ファイル: country.py プロジェクト: gcandal/budy
 def list(self):
     object = appier.get_object(alias = True, find = True)
     countries = budy.Country.find(
         find_i = True,
         find_t = "right",
         map = True,
         **object
     )
     return countries
コード例 #10
0
ファイル: api.py プロジェクト: hivesolutions/crossline
 def facts(self, app = None):
     object = appier.get_object(
         alias = True,
         find = True,
         sort = [("_id", -1)]
     )
     if app: object["app"] = app
     facts = crossline.CounterFact.find(map = True, **object)
     return facts
コード例 #11
0
ファイル: product.py プロジェクト: gcandal/budy
 def search(self):
     object = appier.get_object(alias = True, find = True)
     products = budy.Product.find_s(
         find_t = "both",
         find_n = "tokens",
         eager = ("images", "brand"),
         map = True,
         **object
     )
     return products
コード例 #12
0
ファイル: package.py プロジェクト: hivesolutions/repos
 def artifacts(self, name):
     self.ensure_auth()
     object = appier.get_object(alias = True, find = True)
     artifacts = repos.Artifact.find(
         package = name,
         map = True,
         sort = [("timestamp", -1)],
         **object
     )
     return artifacts
コード例 #13
0
ファイル: account.py プロジェクト: gcandal/budy
 def orders_me(self):
     object = appier.get_object(alias = True, find = True, sort = [("id", -1)])
     account = budy.BudyAccount.from_session()
     orders = budy.Order.find(
         account = account.id,
         paid = True,
         eager = ("lines",),
         map = True,
         **object
     )
     return orders
コード例 #14
0
 def list_requests(self):
     object = appier.get_object(alias=True,
                                page=True,
                                find=True,
                                sort=(("id", -1), ))
     page = models.DiagRequest.paginate(**object)
     requests = models.DiagRequest.find(meta=True, **object)
     return self.template("request/list.html.tpl",
                          section="section:diag:requests",
                          page=page,
                          requests=requests,
                          model=models.DiagRequest)
コード例 #15
0
ファイル: order.py プロジェクト: hivesolutions/shopdesk
 def checker(self):
     object = appier.get_object(
         alias = True,
         find = True,
         limit = 0,
         sort = [("s_id", -1)]
     )
     orders = self.admin_part._find_view(shopdesk.Order, **object)
     return self.template(
         "order/checker.html.tpl",
         orders = orders
     )
コード例 #16
0
ファイル: currency.py プロジェクト: gcandal/budy
    def simple_csv(self):
        object = appier.get_object(
            alias = True,
            find = True,
            limit = 0
        )
        currencies = budy.Currency.find(**object)

        currencies_s = [("iso", "decimal_places")]
        for currency in currencies:
            currency_s = (currency.iso, currency.decimal_places)
            currencies_s.append(currency_s)

        result = appier.serialize_csv(currencies_s, delimiter = ",")
        self.content_type("text/csv")
        return result
コード例 #17
0
 def show_model(self, model):
     model = self.get_model(model)
     object = appier.get_object(
         alias = True,
         page = True,
         find = True
     )
     page = model.paginate(**object)
     object = self._sort(object, model)
     entities = model.find(meta = True, **object)
     return self.template(
         "models/show.html.tpl",
         section = "models",
         model = model,
         page = page,
         entities = entities
     )
コード例 #18
0
    def facts_csv(self, app=None):
        object = appier.get_object(alias=True, find=True, sort=[("_id", -1)])
        if app: object["app"] = app
        facts = crossline.CounterFact.find(map=True, **object)

        buffer = appier.legacy.StringIO()
        writer = csv.writer(buffer, delimiter=";")
        writer.writerow(ROW_ORDER)

        for fact in facts:
            row = []
            for name in ROW_ORDER:
                value = fact[name]
                row.append(value)
            writer.writerow(row)

        data = buffer.getvalue()

        self.content_type("text/csv")
        return data
コード例 #19
0
ファイル: part.py プロジェクト: hivesolutions/appier_extras
    def model_zip(self, model):
        encoding = self.field("encoding", default="utf-8")

        model_c = self.owner.get_model(model)
        object = appier.get_object(alias=True, find=True, limit=0)
        models = self.owner.admin_part._find_view(model_c,
                                                  map=True,
                                                  rules=False,
                                                  **object)

        prefix = "%s-%s" % (self.owner.name, model)

        # creates the in memory file that is going to be used for the storage
        # of the ZIP file that is going to be created
        zip_io = appier.legacy.BytesIO()

        try:
            # creates the ZIP file using the in memory file and then dumps the
            # JSON based data into the associated directory, notice that a proper
            # encoding operation may be required to have a bytes object
            models_s = json.dumps(models)
            if not appier.legacy.is_bytes(models_s):
                models_s = models_s.encode(encoding)
            zip_file = zipfile.ZipFile(zip_io, mode="w", allowZip64=True)
            try:
                zip_file.writestr("%s.json" % prefix, models_s)
            finally:
                zip_file.close()

            # seeks the in memory file back to the initial position
            # and then reads the complete set of contents from it
            zip_io.seek(0)
            data = zip_io.read()
        finally:
            zip_io.close()

        return data
コード例 #20
0
    def list_events_csv(self):
        object = appier.get_object(
            alias = True,
            find = True,
            limit = 0
        )
        events = models.Event.find(**object)

        events_s = [(
            "name",
            "handler",
            "arguments"
        )]
        for event in events:
            event_s = (
                event.name,
                event.handler,
                event.arguments and json.dumps(event.arguments)
            )
            events_s.append(event_s)

        result = appier.serialize_csv(events_s, delimiter = ",")
        self.content_type("text/csv")
        return result
コード例 #21
0
ファイル: api.py プロジェクト: hivesolutions/crossline
    def facts_csv(self, app = None):
        object = appier.get_object(
            alias = True,
            find = True,
            sort = [("_id", -1)]
        )
        if app: object["app"] = app
        facts = crossline.CounterFact.find(map = True, **object)

        buffer = appier.legacy.StringIO()
        writer = csv.writer(buffer, delimiter = ";")
        writer.writerow(ROW_ORDER)

        for fact in facts:
            row = []
            for name in ROW_ORDER:
                value = fact[name]
                row.append(value)
            writer.writerow(row)

        data = buffer.getvalue()

        self.content_type("text/csv")
        return data
コード例 #22
0
ファイル: brand.py プロジェクト: anctemarry27/budy
 def list(self):
     object = appier.get_object(alias = True, find = True)
     brands = budy.Brand.find(map = True, **object)
     return brands
コード例 #23
0
ファイル: order.py プロジェクト: gcandal/budy
 def complex_csv(self):
     start = self.field("start", cast = int)
     end = self.field("end", cast = int)
     paid = self.field("paid", True, cast = bool)
     object = appier.get_object(
         alias = True,
         find = True,
         limit = 0,
         sort = [("id", -1)]
     )
     id = object.get("id", {})
     if start: id["$gte"] = start
     if end: id["$lte"] = end
     if start or end: object["id"] = id
     if paid: object["paid"] = True
     orders = budy.Order.find(**object)
     orders_s = [(
         "id",
         "reference",
         "date",
         "status",
         "email",
         "account",
         "store",
         "product",
         "gender",
         "size",
         "quantity",
         "total",
         "currency",
         "first_name",
         "last_name",
         "billing_address",
         "billing_city",
         "billing_state",
         "billing_postal_code",
         "billing_country",
         "billing_phone",
         "shipping_address",
         "shipping_city",
         "shipping_state",
         "shipping_postal_code",
         "shipping_country",
         "shipping_phone"
     )]
     for order in orders:
         for line in order.lines:
             if not line.product: continue
             account = order.account
             shipping_address = order.shipping_address
             billing_address = order.billing_address
             order_s = (
                 order.id,
                 order.reference,
                 order.created_d.strftime("%d/%m/%Y"),
                 order.status,
                 order.email,
                 account.username,
                 order.store and order.store.name,
                 line.product.short_description,
                 line.product.gender,
                 line.size,
                 line.quantity,
                 line.total,
                 line.currency,
                 billing_address.first_name,
                 billing_address.last_name,
                 billing_address.address,
                 billing_address.city,
                 billing_address.state,
                 billing_address.postal_code,
                 billing_address.country,
                 billing_address.phone_number,
                 shipping_address and shipping_address.address,
                 shipping_address and shipping_address.city,
                 shipping_address and shipping_address.state,
                 shipping_address and shipping_address.postal_code,
                 shipping_address and shipping_address.country,
                 shipping_address and shipping_address.phone_number
             )
             orders_s.append(order_s)
     result = appier.serialize_csv(orders_s, delimiter = ",")
     self.content_type("text/csv")
     return result
コード例 #24
0
ファイル: order.py プロジェクト: gcandal/budy
 def list(self):
     object = appier.get_object(alias = True, find = True, sort = [("id", -1)])
     orders = budy.Order.find(eager_l = True, map = True, **object)
     return orders
コード例 #25
0
ファイル: order.py プロジェクト: gcandal/budy
 def ctt_csv(self):
     start = self.field("start", cast = int)
     end = self.field("end", cast = int)
     paid = self.field("paid", True, cast = bool)
     sms = self.field("sms", False, cast = bool)
     object = appier.get_object(
         alias = True,
         find = True,
         limit = 0,
         sort = [("id", -1)]
     )
     id = object.get("id", {})
     if start: id["$gte"] = start
     if end: id["$lte"] = end
     if start or end: object["id"] = id
     if paid: object["paid"] = True
     orders = budy.Order.find(**object)
     orders_s = []
     for order in orders:
         shipping_address = order.shipping_address
         postal_code = shipping_address.postal_code or ""
         if not "-" in postal_code: postal_code += "-"
         weight = "%.2f" % (order.quantity * 100)
         weight = weight.replace(".", ",")
         line = dict(
             reference = order.reference,
             quantity = int(order.quantity),
             weight = weight,
             price = "0ue",
             destiny = shipping_address.full_name[:60],
             title = order.account.title[:20],
             name = shipping_address.full_name[:60],
             address = shipping_address.address[:60],
             town = shipping_address.city[:50],
             zip_code_4 = postal_code.split("-", 1)[0][:4],
             zip_code_3 = postal_code.split("-", 1)[1][:3],
             not_applicable_1 = "",
             observations = "",
             back = 0,
             document_code = "",
             phone_number = (shipping_address.phone_number or "").replace("+", "00")[:15],
             saturday = 0,
             email = (order.email or "")[:200],
             country = order.country,
             fragile = 0,
             not_applicable_2 = "",
             document_collection = "",
             code_email = "",
             mobile_phone = (shipping_address.phone_number or "").replace("+", "00")[:15],
             second_delivery = 0,
             delivery_date = "",
             return_signed_document = 0,
             expeditor_instructions = 0,
             sms = 1 if sms else 0,
             not_applicable_3 = "",
             printer = "",
             ticket_machine = "",
             at_code = ""
         )
         order_s = (
             line["reference"],
             str(line["quantity"]),
             line["weight"],
             line["price"],
             line["destiny"],
             line["title"],
             line["name"],
             line["address"],
             line["town"],
             line["zip_code_4"],
             line["zip_code_3"],
             line["not_applicable_1"],
             line["observations"],
             str(line["back"]),
             line["document_code"],
             line["phone_number"],
             str(line["saturday"]),
             line["email"],
             line["country"],
             str(line["fragile"]),
             line["not_applicable_2"],
             line["document_collection"],
             line["code_email"],
             line["mobile_phone"],
             str(line["second_delivery"]),
             line["delivery_date"],
             str(line["return_signed_document"]),
             str(line["expeditor_instructions"]),
             str(line["sms"]),
             line["not_applicable_3"],
             line["printer"],
             line["ticket_machine"],
             line["at_code"]
         )
         orders_s.append(order_s)
     result = appier.serialize_csv(orders_s, delimiter = "+")
     self.content_type("text/csv")
     return result
コード例 #26
0
ファイル: shopify.py プロジェクト: hivesolutions/shopdesk
 def order_updated(self):
     object = appier.get_object()
     name = object["name"]
     order = shopdesk.Order.get(s_name = name)
     order.sync_shopify_s()
コード例 #27
0
 def facts(self, app=None):
     object = appier.get_object(alias=True, find=True, sort=[("_id", -1)])
     if app: object["app"] = app
     facts = crossline.CounterFact.find(map=True, **object)
     return facts
コード例 #28
0
 def subscriptions_json(self, name):
     object = appier.get_object(alias = True, find = True)
     subscriptions = campaigner.Subscription.find(campaign = name, map = True, **object)
     return subscriptions
コード例 #29
0
ファイル: referral.py プロジェクト: gcandal/budy
 def list(self):
     object = appier.get_object(alias = True, find = True)
     referrals = budy.Referral.find(map = True, **object)
     return referrals
コード例 #30
0
 def list(self):
     object = appier.get_object(alias=True, find=True, limit=0)
     some_models = ripe_skeleton.SomeModel.find_v(map=True, **object)
     return some_models
コード例 #31
0
ファイル: package.py プロジェクト: hivesolutions/repos
 def list(self):
     self.ensure_auth()
     object = appier.get_object(alias = True, find = True)
     packages = repos.Package.find(map = True, **object)
     return packages
コード例 #32
0
 def create(self, id):
     node = appier.get_object()
     self.owner.nodes[id] = node
コード例 #33
0
ファイル: color.py プロジェクト: anctemarry27/budy
 def list(self):
     object = appier.get_object(alias = True, find = True)
     colors = budy.Color.find(map = True, **object)
     return colors
コード例 #34
0
ファイル: voucher.py プロジェクト: gcandal/budy
 def list(self):
     object = appier.get_object(alias = True, find = True, sort = [("id", -1)])
     vouchers = budy.Voucher.find(map = True, **object)
     return vouchers
コード例 #35
0
 def _labels(self, *args, **kwargs):
     object = appier.get_object(alias=True, find=True, limit=0)
     kwargs.update(object)
     return self.admin_part._find_view(toolis.Label, *args, **kwargs)
コード例 #36
0
 def list_json(self):
     object = appier.get_object(alias = True, find = True)
     campaigns = campaigner.Campaign.find(map = True, **object)
     return campaigns
コード例 #37
0
 def enter(self, app=None):
     return crossline.CounterFact.increment_s(app,
                                              adapters=self.adapters,
                                              action="enter",
                                              payload=appier.get_object())
コード例 #38
0
 def subscriptions_csv(self, name):
     object = appier.get_object(alias = True, find = True)
     subscriptions = campaigner.Subscription.find(campaign = name, map = True, **object)
     result = appier.serialize_csv(subscriptions)
     self.content_type("text/csv")
     return result
コード例 #39
0
ファイル: category.py プロジェクト: gcandal/budy
 def list(self):
     object = appier.get_object(alias = True, find = True)
     categories = budy.Category.find(map = True, **object)
     return categories