Exemple #1
0
def get_solution_settings(service_user):
    """
    Args:
        service_user (users.User)
    Returns:
        SolutionSettings
    """
    return SolutionSettings.get(SolutionSettings.create_key(service_user))
Exemple #2
0
def _re_provision(sln_settings_key):
    sln_settings = SolutionSettings.get(sln_settings_key)
    if 'order' in sln_settings.modules and not sln_settings.updates_pending:
        menu = RestaurantMenu.get(
            RestaurantMenu.create_key(sln_settings.service_user,
                                      sln_settings.solution))
        if menu:
            for category in menu.categories:
                for item in category.items:
                    if not item.has_price:
                        common_provision(sln_settings.service_user)
                        return
Exemple #3
0
def job():
    countdown = 0
    for old_export in SolutionLoyaltyExport.all():
        date_int = old_export.year_month
        year = date_int / 100
        month = date_int % 100
        first_day_of_month = int(time.mktime(date(year, month, day=1).timetuple()))
        first_day_of_next_month = int(time.mktime(get_next_month(year, month).timetuple()))
        service_user_email = old_export.parent_key().name()
        sln_settings = SolutionSettings.get(SolutionSettings.create_key(users.User(service_user_email)))
        deferred.defer(create_loyalty_statistics_for_service, sln_settings, first_day_of_month,
                       first_day_of_next_month, _countdown=countdown)
        countdown += 15
Exemple #4
0
def load_loyalty_export_list(cursor=None):
    service_user = users.get_current_user()
    session_ = users.get_current_session()
    service_identity = session_.service_identity
    sln_settings = SolutionSettings.get(SolutionSettings.create_key(service_user))
    exports_q = SolutionLoyaltyExport.list_by_service_user(service_user, service_identity)
    exports_q.with_cursor(cursor)
    exports_list = exports_q.fetch(10)
    cursor = unicode(exports_q.cursor())
    to = SolutionLoyaltyExportListTO.create(cursor,
                                            [SolutionLoyaltyExportTO.from_model(e, sln_settings.main_language)
                                             for e in exports_list])
    return to
Exemple #5
0
def remind_user_with_expired_vouchers(sln_settings_key, today_timestamp):
    """Remind voucher owners (users) before the expiration date by n days"""
    sln_settings = SolutionSettings.get(sln_settings_key)
    if not sln_settings:
        return

    customer = Customer.get_by_service_email(sln_settings.service_user.email())
    if not customer:
        return

    for days in EXPIRED_VOUCHERS_REMINDER:
        run_job(expired_vouchers_qry,
                [customer.app_id, today_timestamp + days],
                send_expired_voucher_message, [sln_settings, days / DAY])
def _re_provision(sln_settings_key):
    sln_settings = SolutionSettings.get(sln_settings_key)
    if sln_settings.updates_pending == False:
        logging.info('Provisioning %s', sln_settings.name)
        allow_transaction_propagation(run_in_xg_transaction, common_provision,
                                      sln_settings.service_user, sln_settings)
Exemple #7
0
def _publish_events_app_data(sln_settings_key):
    sln_settings = SolutionSettings.get(sln_settings_key)
    _publish_app_data(sln_settings)