def _config_object(self): from models.config.config import Config try: self._local.config except AttributeError: self._local.config = Config.get() else: if not self._local.config or self._local.config.key.namespace() != namespace_manager.get_namespace(): self._local.config = Config.get() return self._local.config
def post(self): config = Config.get() config.APP_NAME = self.request.get('name') config.COMPANY_DESCRIPTION = self.request.get('info') config.SUPPORT_PHONE = self.request.get('phone') config.SUPPORT_SITE = self.request.get('site') config.SUPPORT_EMAILS = self.request.get('emails').split(',') config.REPORT_EMAILS = self.request.get('report_emails') config.REPORT_WEEKLY = self.request.get('report_weekly') == '1' config.ACTION_COLOR = "FF%s" % self.request.get('color')[1:] config.EMAIL_REQUESTS = bool(self.request.get('email_buttons')) config.COMPANY_STATUS = int(self.request.get('company_status')) if self.request.get('image_file') or self.request.get('image_url'): if self.request.get('image_file'): new_url = get_new_image_url('Company', config.key.id(), image_data=str(self.request.get('image_file')), size=250.0) elif self.request.get('image_url') and self.request.get('image_url') != config.COMPANY_LOGO_URL: new_url = get_new_image_url('Company', config.key.id(), url=self.request.get('image_url'), size=250.0) else: new_url = None if new_url: config.COMPANY_LOGO_URL = new_url config.put() self.redirect('/company/docs/about')
def post(self): config = Config.get() config.PARSE_APP_API_KEY = self.request.get('app_key') config.PARSE_CLIENT_API_KEY = self.request.get('client_key') config.PARSE_REST_API_KEY = self.request.get('rest_key') config.put() self.redirect('/company/notifications/pushes/list')
def post(self): if self.user is not None: self.success() login, password, password2 = \ self.request.get("email").strip().lower(), \ self.request.get("password"), self.request.get("password2") namespace = latinize(login) error = None for metadata_instance in metadata.get_namespaces(): if namespace == metadata_instance: error = u"Введите другой email" if error: pass elif not login: error = u"Не введен email" elif not password: error = u"Не введен пароль" elif password != password2: error = u"Пароли не совпадают" else: values = { 'namespace': namespace, 'login': login, 'password_raw': password, 'rights': CompanyUser.RIGHTS_MASK_ADMIN, } success, user = CompanyUser.create_user(login, **values) if not success: error = u"Пользователь с этим email уже зарегистрирован" else: set_current_user(self.auth, user) if error: logging.info(error) self.render('/signup.html', email=login, error=error) else: namespace_manager.set_namespace(namespace) cfg = Config(id=1) cfg.REPORT_EMAILS = '*****@*****.**' cfg.put() DeliverySlot(name=u'Сейчас', slot_type=0, value=0).put() DeliverySlot(name=u'Через 5 минут', slot_type=0, value=5).put() DeliverySlot(name=u'Через 10 минут', slot_type=0, value=10).put() DeliverySlot(name=u'Через 15 минут', slot_type=0, value=15).put() DeliverySlot(name=u'Через 20 минут', slot_type=0, value=20).put() DeliverySlot(name=u'Через 25 минут', slot_type=0, value=25).put() DeliverySlot(name=u'Через 30 минут', slot_type=0, value=30).put() self.success()
def post(self): config = Config.get() config.PROMOS_API_KEY = self.request.get('promo_api_key') if not config.PROMOS_API_KEY: config.PROMOS_API_KEY = None config.WALLET_API_KEY = self.request.get('wallet_api_key') if not config.WALLET_API_KEY: config.WALLET_API_KEY = None config.put() self.redirect('/company/promos/list')
def _get_ios_values(): config = Config.get() appearance = config.GET_APP_APPEARANCE_IOS return { 'base_color': appearance.base_color, 'base_text_color': appearance.base_text_color, 'additional_text_color': appearance.additional_text_color, 'error_color': appearance.error_color, 'topbar_color': appearance.topbar_color, 'topbar_text_color': appearance.topbar_text_color, 'menu_header_color': appearance.menu_header_color, }
def get_version(version, create=False): version = int(version) version_obj = None cfg = Config.get() for version_obj in cfg.VERSIONS: if version_obj.number == version: return version_obj if create: now = datetime.utcnow() version_obj = Version(created=now, updated=now, number=version) cfg.VERSIONS.append(version_obj) cfg.put() return version_obj
def _get_android_values(): config = Config.get() appearance = config.GET_APP_APPEARANCE_ANDROID return { 'base_color': appearance.base_color, 'base_text_color': appearance.base_text_color, 'additional_text_color': appearance.additional_text_color, 'error_color': appearance.error_color, 'statusbar_color': appearance.statusbar_color, 'navigation_bar_color': appearance.navigation_bar_color, 'toolbar_color': appearance.toolbar_color, 'toolbar_text_color': appearance.toolbar_text_color, }
def update_address(self): from models.config.config import Config from methods import geocoder candidates = geocoder.get_houses_by_coordinates( self.coordinates.lat, self.coordinates.lon) if candidates: address = candidates[0] self.address = Address(**address['address']) cfg = Config.get() if self.address.country not in cfg.COUNTRIES: cfg.COUNTRIES.append(self.address.country) cfg.put() self.update_timezone()
def post(self): cfg = Config.get() cfg.ALFA_BASE_URL = 'https://engine.paymentgate.ru/payment' if self.request.get('alfa') == 'production' \ else 'https://test.paymentgate.ru/testpayment' cfg.ALFA_LOGIN = self.request.get('bind_login') cfg.ALFA_PASSWORD = self.request.get('bind_password') cfg.put() legals = LegalInfo.query().fetch() for legal in legals: legal.alfa_login = self.request.get('login_%s' % legal.key.id()) legal.alfa_password = self.request.get('password_%s' % legal.key.id()) legal.put() self.redirect('/company/main')
def update_hit_category(): cfg = Config.get() if cfg.HIT_MODULE and cfg.HIT_MODULE.status == STATUS_AVAILABLE: module = cfg.HIT_MODULE items = [] for item in MenuItem.query().order(-MenuItem.rating).fetch(): if len(items) >= module.max_item_amount - len( module.cunning_items): break if item.status == STATUS_UNAVAILABLE: continue if item.rating < module.min_item_rating: break items.append(item.key) items.extend(module.cunning_items) module.items = items cfg.put()
def post(self): logging.info(self.request) config = Config.get() appearance = config.GET_APP_APPEARANCE_IOS appearance.base_color = "FF%s" % self.request.get('base_color')[1:] appearance.base_text_color = "FF%s" % self.request.get( 'base_text_color')[1:] appearance.additional_text_color = "FF%s" % self.request.get( 'additional_text_color')[1:] appearance.error_color = "FF%s" % self.request.get('error_color')[1:] appearance.topbar_color = "FF%s" % self.request.get('topbar_color')[1:] appearance.topbar_text_color = "FF%s" % self.request.get( 'topbar_text_color')[1:] appearance.menu_header_color = "FF%s" % self.request.get( 'menu_header_color')[1:] config.put() self.redirect('/company/app_appearance/list')
def check_geo_push(client, order): push = GeoPush.query(GeoPush.client == client.key, GeoPush.status == STATUS_AVAILABLE).get() success = False if push: config = Config.get() last_day = datetime.utcnow() - timedelta( days=config.GEO_PUSH_MODULE.days_without_order) last_order = Order.query(Order.date_created > last_day, Order.client_id == client.key.id(), Order.status.IN(NOT_CANCELED_STATUSES)).get() if not last_order: success = True if order: order.geo_push = push.key push.deactivate() return success
def post(self): logging.info(self.request) config = Config.get() appearance = config.GET_APP_APPEARANCE_ANDROID appearance.base_color = "FF%s" % self.request.get('base_color')[1:] appearance.base_text_color = "FF%s" % self.request.get( 'base_text_color')[1:] appearance.additional_text_color = "FF%s" % self.request.get( 'additional_text_color')[1:] appearance.error_color = "FF%s" % self.request.get('error_color')[1:] appearance.statusbar_color = "FF%s" % self.request.get( 'statusbar_color')[1:] appearance.navigation_bar_color = "FF%s" % self.request.get( 'navigation_bar_color')[1:] appearance.toolbar_color = "FF%s" % self.request.get( 'toolbar_color')[1:] appearance.toolbar_text_color = "FF%s" % self.request.get( 'toolbar_text_color')[1:] config.put() self.redirect('/company/app_appearance/list')
def post(self): status = bool(self.request.get('status')) header = self.request.get('header') text = self.request.get('text') inactivity_duration = self.request.get_range('inactivity_duration') days_since_order = self.request.get_range('days_since_order') cnf = Config.get() module = cnf.BASKET_NOTIFICATION_MODULE if not module: module = BasketNotificationModule() cnf.BASKET_NOTIFICATION_MODULE = module module.status = status module.header = header module.text = text module.inactivity_duration = inactivity_duration module.days_since_order = days_since_order cnf.put() self.redirect_to('config_main')
def post(self): data = json.loads(self.request.body) name, phone, email = map(data['info'].get, ('name', 'phone', 'email')) phone = '7' + ''.join(c for c in phone if '0' <= c <= '9') namespace = self._find_namespace(name) password = "******" % random.randint(0, 10000) CompanyUser.create_user(namespace, namespace=namespace, password_raw=password, login=namespace, rights=CompanyUser.RIGHTS_MASK_ADMIN) namespace_manager.set_namespace(namespace) cfg = Config(id=1) cfg.APP_NAME = name cfg.DELIVERY_PHONES = [phone] cfg.DELIVERY_EMAILS = ['*****@*****.**', email] cfg.SUPPORT_EMAILS = [email] cfg.ACTION_COLOR = "FF25B8CD" cfg.put() delivery_slot_keys = [ DeliverySlot(name=u'Сейчас', slot_type=0, value=0).put(), DeliverySlot(name=u'Через 5 минут', slot_type=0, value=5).put(), DeliverySlot(name=u'Через 10 минут', slot_type=0, value=10).put(), DeliverySlot(name=u'Через 15 минут', slot_type=0, value=15).put(), DeliverySlot(name=u'Через 20 минут', slot_type=0, value=20).put(), DeliverySlot(name=u'Через 25 минут', slot_type=0, value=25).put(), DeliverySlot(name=u'Через 30 минут', slot_type=0, value=30).put() ] menu = data['menu'] init = MenuCategory(category=None, title="Init") init.put() for i, category_dict in enumerate(menu): MenuCategory.generate_category_sequence_number( ) # only to increase counter category = MenuCategory(title=category_dict["title"], sequence_number=i, category=init.key) category.put() for j, item in enumerate(category_dict["items"]): MenuItem(category=category.key, title=item["title"], description=item["description"], picture=item["imageUrl"], price=int(round(float(item["price"]) * 100)), sequence_number=j).put() for _ in category.get_items(): category.generate_sequence_number() # only to increase counter venue_dict = data['venue'] venue = Venue(title=venue_dict['title'], description=venue_dict['address'], coordinates=ndb.GeoPt(venue_dict['lat'], venue_dict['lng']), active=True) venue.update_address() venue.schedule = Schedule(days=[ DaySchedule( weekday=i, start=datetime.time(0, 0), end=datetime.time(0, 0)) for i in xrange(1, 8) ]) for delivery_type in (SELF, IN_CAFE): delivery = DeliveryType.create(delivery_type) delivery.put() delivery.status = STATUS_AVAILABLE delivery.max_time = DAY_SECONDS + HOUR_SECONDS # need hour to order on tomorrow delivery.delivery_slots = delivery_slot_keys venue.delivery_types.append(delivery) venue.put() PaymentType(id=str(CASH_PAYMENT_TYPE), title="cash", status=STATUS_AVAILABLE).put() deferred.defer(_notify_sms, phone, namespace, password) deferred.defer(_notify_email, email, phone, name, namespace, password) self.render_json({'login': namespace, 'password': password})