當前位置: 首頁>>代碼示例>>Python>>正文


Python App.auto_connected_services方法代碼示例

本文整理匯總了Python中rogerthat.models.App.auto_connected_services方法的典型用法代碼示例。如果您正苦於以下問題:Python App.auto_connected_services方法的具體用法?Python App.auto_connected_services怎麽用?Python App.auto_connected_services使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rogerthat.models.App的用法示例。


在下文中一共展示了App.auto_connected_services方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import auto_connected_services [as 別名]
    def post(self):
        success = False
        app_id = self.request.POST.get("app_id", None)
        name = self.request.POST.get("name", None)
        app_type = self.request.POST.get("app_type", None)
        fb_app_id = self.request.POST.get("fb_app_id", None)
        ios_app_id = self.request.POST.get("ios_app_id", None)
        android_app_id = self.request.POST.get("android_app_id", None)
        dashboard_email_address = self.request.POST.get('dashboard_email_address', None)
        contact_email_address = self.request.POST.get("contact_email_address", None)
        user_regex = self.request.POST.get("user_regex", None)
        qr_templates_count = int(self.request.POST.get("qr_templates_count", 0))
        default_qr_template_index = int(self.request.POST.get("default_qr_template_index", 0))
        auto_connected_services_string = self.request.POST.get("auto_connected_services", "[]")
        logging.debug("auto_connected_services = %s", auto_connected_services_string)
        beacon_major_str = self.request.POST.get("beacon_major", 0)
        beacon_major = int(beacon_major_str) if beacon_major_str else 0
        demo = bool(self.request.POST.get("demo", ''))
        beta = bool(self.request.POST.get("beta", ''))
        mdp_client_id = self.request.POST.get('mdp_client_id', None)
        mdp_client_secret = self.request.POST.get('mdp_client_secret', None)
        orderable_apps = self.request.get_all('orderable_apps')
        auto_connected_services = parse_complex_value(AutoConnectedService,
                                                      json.loads(auto_connected_services_string),
                                                      True)
        admin_services = json.loads(self.request.POST.get('admin_services', '[]'))
        beacon_regions = json.loads(self.request.POST.get("beacon_regions", "[]"))

        try:
            app_type = None if not app_type else int(app_type)
        except Exception:
            app_type = None

        try:
            fb_app_id = None if not fb_app_id else int(fb_app_id)
        except Exception:
            fb_app_id = None

        if not app_id:
            result = "Failed to create new app (app_id was empty)!"
        elif [c for c in app_id if c not in '-abcdefghijklmnopqrstuvwxyz0123456789']:
            result = "App ids should only contain (-, lower case alphabet characters and numbers)"
        elif not name:
            result = "Failed to create new app (name was empty)!"
        elif app_type is None:
            result = "Failed to create new app (app_type was empty)!"
        elif not ios_app_id:
            result = "Failed to create new app (ios_app_id was empty)!"
        elif not android_app_id:
            result = "Failed to create new app (android_app_id was empty)!"
        elif not dashboard_email_address:
            result = "Failed to create new app (dashboard_email_address was empty)!"
        else:
            try:
                if user_regex:
                    validate_user_regex(user_regex)

                zip_stream = self.request.POST.get('core_branding').file
                zip_stream.seek(0)
                try:
                    zip_ = ZipFile(zip_stream)
                except BadZipfile, e:
                    raise BrandingValidationException(e.message)

                branding = store_branding_zip(None, zip_, u"Core branding of %s" % app_id)

                app = App(key=App.create_key(app_id))
                to_be_put = []
                app.qrtemplate_keys = []
                for i in xrange(qr_templates_count):
                    file_ = self.request.POST.get('qr_template_%s' % i)
                    description = self.request.POST.get("qr_template_description_%s" % i)
                    color = self.request.POST.get("qr_template_color_%s" % i)
                    file_ = file_.file.getvalue() if isinstance(file_, FieldStorage) else None
                    key_name = create_qr_template_key_name(app_id, description)
                    store_template(None, file_, description, color, key_name)
                    if default_qr_template_index == i:
                        app.qrtemplate_keys.insert(0, key_name)
                    else:
                        app.qrtemplate_keys.append(key_name)

                app.name = name
                app.type = app_type
                app.core_branding_hash = branding.hash
                app.facebook_app_id = fb_app_id
                app.ios_app_id = ios_app_id
                app.android_app_id = android_app_id
                app.dashboard_email_address = dashboard_email_address
                app.contact_email_address = contact_email_address
                app.user_regex = user_regex
                app.creation_time = now()
                app.is_default = get_default_app_key() is None
                app.demo = demo
                app.beta = beta
                app.mdp_client_id = mdp_client_id or None
                app.mdp_client_secret = mdp_client_secret or None

                app.auto_connected_services = AutoConnectedServices()
                for acs in auto_connected_services:
                    service_identity_user = add_slash_default(users.User(acs.service_identity_email))
#.........這裏部分代碼省略.........
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:103,代碼來源:apps.py


注:本文中的rogerthat.models.App.auto_connected_services方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。