Beispiel #1
0
def rest_delete_news(news_id):
    try:
        delete_news(news_id)
        return ReturnStatusTO.create(True, None)
    except ServiceApiException as e:
        logging.exception(e)
        return ReturnStatusTO.create(False, None)
Beispiel #2
0
def restapi_add_city_postal_code(app_id, postal_code):
    try:
        sln_settings = can_edit_city_postal_codes()
        add_city_postal_code(app_id, postal_code)
        return RETURNSTATUS_TO_SUCCESS
    except ValueError:
        return ReturnStatusTO.create(False, common_translate(sln_settings.main_language,
                                     SOLUTION_COMMON, u'invlid_postal_code'))
    except BusinessException as e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #3
0
def update_vouchers_validity(app_id, validity):
    """Sets the vouchers validity in months"""
    sln_settings = get_solution_settings(users.get_current_user())
    if SolutionModule.CITY_VOUCHERS not in sln_settings.modules:
        return ReturnStatusTO.create(False, 'no_permission')

    if isinstance(validity, (int, long)) and validity < 1:
        return ReturnStatusTO.create(False, 'invalid_validity_period')

    voucher_settings = get_city_vouchers_settings(app_id)
    if not voucher_settings:
        voucher_settings = SolutionCityVoucherSettings(key=SolutionCityVoucherSettings.create_key(app_id))
    voucher_settings.validity = validity
    voucher_settings.put()
    return RETURNSTATUS_TO_SUCCESS
Beispiel #4
0
def restapi_remove_city_postal_codes(app_id, postal_code):
    try:
        can_edit_city_postal_codes()
        remove_city_postal_code(app_id, postal_code)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException as e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #5
0
def remove_order_weekday_timeframe(timeframe_id):
    service_user = users.get_current_user()
    try:
        delete_order_weekday_timeframe(service_user, timeframe_id)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #6
0
def order_send_message(order_key, order_status, message):
    service_user = users.get_current_user()
    try:
        send_message_for_order(service_user, order_key, order_status, message)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
def end_log_forwarding(app_user_email, xmpp_target):
    try:
        stop_debugging(users.User(app_user_email), xmpp_target, None, False)
        return RETURNSTATUS_TO_SUCCESS
    except Exception, e:
        logging.debug("Failed to stop log forwarding", exc_info=True)
        return ReturnStatusTO.create(False, str(e))
Beispiel #8
0
def delete_loyalty_lottery_info(key):
    ll_info_delete = SolutionLoyaltyLottery.get(key)
    if not ll_info_delete:
        return RETURNSTATUS_TO_SUCCESS

    service_user = users.get_current_user()
    session_ = users.get_current_session()
    service_identity = session_.service_identity
    sln_settings = get_solution_settings(service_user)

    try:
        ll_info = SolutionLoyaltyLottery.load_pending(service_user, service_identity)
        if ll_info_delete.key() == ll_info.key():
            raise RETURNSTATUS_TO_SUCCESS
        if ll_info_delete.schedule_loot_time > 0:
            ll_info_delete.delete()

        sln_settings.updates_pending = True
        put_and_invalidate_cache(sln_settings)
        broadcast_updates_pending(sln_settings)

        send_message(service_user, u"solutions.common.loyalty.lottery.update", service_identity=service_identity)

        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, common_translate(sln_settings.main_language, SOLUTION_COMMON, e.message))
Beispiel #9
0
def order_delete(order_key, message):
    service_user = users.get_current_user()
    try:
        delete_pharmacy_order(service_user, order_key, message)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #10
0
def edit_reservation_tables(reservation_key, tables):
    from solutions.common.bizz.reservation import edit_reservation_tables as edit_reservation_tables_bizz
    try:
        edit_reservation_tables_bizz(users.get_current_user(), reservation_key, tables)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #11
0
def add_city_wide_lottery_info(city_app_id, winnings, date, x_winners):
    service_user = users.get_current_user()
    sln_settings = get_solution_settings(service_user)
    try:
        now_ = now()
        end_timestamp = date.toEpoch()
        if end_timestamp <= (now_ + 24 * 3600):
            raise BusinessException("end-date-24h-in-future")

        ll_info = SolutionCityWideLottery.load_pending(city_app_id)
        if ll_info:
            logging.warn("end_timestamp: %s", end_timestamp)
            logging.warn("ll_info.end_timestamp: %s", ll_info.end_timestamp)
            if end_timestamp <= ll_info.end_timestamp:
                raise BusinessException("lottery-time-bigger-first-upcoming")

        ll_info = SolutionCityWideLottery(parent=SolutionCityWideLottery.create_parent_key(city_app_id))
        ll_info.timestamp = now_
        ll_info.end_timestamp = end_timestamp
        ll_info.schedule_loot_time = ll_info.end_timestamp - 24 * 3600
        ll_info.winnings = winnings
        ll_info.x_winners = x_winners
        ll_info.winners = []
        ll_info.winner_info = []
        ll_info.skip_winners = []
        ll_info.deleted = False
        ll_info.pending = True
        ll_info.put()

        send_message(service_user, u"solutions.common.loyalty.lottery.update")

        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, common_translate(sln_settings.main_language, SOLUTION_COMMON, e.message))
def schedule_broadcast(broadcast_key, timestamp):
    from rogerthat.bizz.service.broadcast import schedule_broadcast as bizz_schedule_broadcast
    try:
        bizz_schedule_broadcast(users.get_current_user(), broadcast_key, timestamp)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, be:
        return ReturnStatusTO.create(False, be.message)
def rm_broadcast(broadcast_key):
    from rogerthat.bizz.service.broadcast import delete_broadcast
    try:
        delete_broadcast(users.get_current_user(), broadcast_key)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, be:
        return ReturnStatusTO.create(False, be.message)
Beispiel #14
0
def edit_city_wide_lottery_info(key, winnings, date, x_winners):
    ll_info_edit = SolutionCityWideLottery.get(key)
    if not ll_info_edit:
        return RETURNSTATUS_TO_SUCCESS

    service_user = users.get_current_user()
    sln_settings = get_solution_settings(service_user)

    try:
        now_ = now()
        end_timestamp = date.toEpoch()
        if end_timestamp <= (now_ + 24 * 3600):
            raise BusinessException("end-date-24h-in-future")

        ll_info = SolutionCityWideLottery.load_pending(ll_info_edit.app_id)
        if ll_info_edit.key() != ll_info.key() and end_timestamp <= ll_info.end_timestamp:
            raise BusinessException("lottery-time-bigger-first-upcoming")

        ll_info_edit.end_timestamp = end_timestamp
        ll_info_edit.schedule_loot_time = ll_info_edit.end_timestamp - 24 * 3600
        ll_info_edit.winnings = winnings
        ll_info_edit.x_winners = x_winners
        ll_info_edit.put()

        send_message(service_user, u"solutions.common.loyalty.lottery.update")

        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, common_translate(sln_settings.main_language, SOLUTION_COMMON, e.message))
def add_broadcast_type(broadcast_type):
    from rogerthat.bizz.service.broadcast import add_broadcast_type as bizz_add_broadcast_type
    try:
        bizz_add_broadcast_type(users.get_current_user(), broadcast_type)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, be:
        return ReturnStatusTO.create(False, be.message)
def delete_service_identity(identifier):
    from rogerthat.bizz.service import delete_service_identity as delete_service_identity_bizz

    try:
        delete_service_identity_bizz(users.get_current_user(), identifier)
    except BusinessException, be:
        logging.warn(be.message, exc_info=True)
        return ReturnStatusTO.create(False, be.message)
def delete_service_role(role_id):
    service_user = users.get_current_user()
    from rogerthat.bizz.roles import delete_service_role as delete_service_role_bizz
    try:
        delete_service_role_bizz(service_user, role_id)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, be:
        return ReturnStatusTO.create(False, be.message)
def create_service_identity(details):
    from rogerthat.bizz.service import create_service_identity as create_service_identity_bizz

    try:
        create_service_identity_bizz(users.get_current_user(), details)
    except BusinessException, be:
        logging.warn(be.message, exc_info=True)
        return ReturnStatusTO.create(False, be.message)
 def post(self):
     try:
         mobile_id = self.request.POST["mobile_id"]
         user = users.get_current_user()
         start_debugging(user, mobile_id)
         return_status = RETURNSTATUS_TO_SUCCESS
     except BusinessException, e:
         return_status = ReturnStatusTO.create(success=False, errormsg=e.message)
Beispiel #20
0
def delete_loyalty_visit(key):
    service_user = users.get_current_user()
    try:
        delete_visit(service_user, key)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        sln_settings = get_solution_settings(service_user)
        return ReturnStatusTO.create(False, common_translate(sln_settings.main_language, SOLUTION_COMMON, e.message))
Beispiel #21
0
def save_order_weekday_timeframe(timeframe_id, day, time_from, time_until):
    service_user = users.get_current_user()
    try:
        put_order_weekday_timeframe(service_user, timeframe_id, day, time_from,
                                    time_until)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #22
0
def delete_loyalty_slide(slide_id):
    service_user = users.get_current_user()
    session_ = users.get_current_session()
    service_identity = session_.service_identity
    try:
        loyalty_bizz.delete_loyalty_slide(service_user, service_identity, slide_id)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
def update_service_identity(details):
    from rogerthat.bizz.service import update_service_identity as update_service_identity_bizz

    try:
        update_service_identity_bizz(users.get_current_user(), details)
    except InvalidValueException, ive:
        reason = ive.fields['reason']
        logging.debug("%s: %s", ive.message, ive.fields, exc_info=True)
        return ReturnStatusTO.create(False, reason)
def grant_admin_role(user_email, role, identity):
    service_user = users.get_current_user()
    service_identity_user = create_service_identity_user(service_user, identity)
    from rogerthat.bizz.roles import grant_role as grant_role_bizz
    try:
        grant_role_bizz(service_identity_user, users.User(user_email), role)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #25
0
def reply_reservation(email, app_id, message, reservation_key=None):
    from solutions.common.bizz.reservation import reply_reservation as reply_reservation_bizz
    try:
        if reservation_key is MISSING:
            reservation_key = None
        reply_reservation_bizz(users.get_current_user(), email, app_id, message, reservation_key)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #26
0
    def trans():
        cap = get_cityapp_profile(service_user)
        if success:
            cap.uitdatabank_enabled = True
            cap.put()
            return RETURNSTATUS_TO_SUCCESS

        cap.uitdatabank_enabled = False
        cap.put()
        return ReturnStatusTO.create(False, result)
Beispiel #27
0
def update_loyalty_admin(admin_app_user_email, admin_name, admin_functions):
    service_user = users.get_current_user()
    session_ = users.get_current_session()
    service_identity = session_.service_identity
    try:
        loyalty_bizz.update_loyalty_admin(
            service_user, service_identity, admin_app_user_email, admin_name, admin_functions)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #28
0
def save_shifts(shifts):
    from solutions.common.bizz.reservation import save_shifts as save_shifts_bizz
    try:
        service_user = users.get_current_user()
        session_ = users.get_current_session()
        service_identity = session_.service_identity
        save_shifts_bizz(service_user, service_identity, shifts)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #29
0
def update_table(table):
    from solutions.common.bizz.reservation import update_table as update_table_bizz
    try:
        service_user = users.get_current_user()
        session_ = users.get_current_session()
        service_identity = session_.service_identity
        update_table_bizz(service_user, service_identity, table)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
def rm_broadcast_test_person(email, app_id=None):
    from rogerthat.bizz.service.broadcast import delete_broadcast_test_person
    service_user = users.get_current_user()
    default_service_identity_user = create_service_identity_user(service_user, ServiceIdentity.DEFAULT)
    app_id = get_and_validate_app_id_for_service_identity_user(default_service_identity_user, app_id, email)
    try:
        delete_broadcast_test_person(users.get_current_user(), create_app_user(users.User(email), app_id))
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, be:
        return ReturnStatusTO.create(False, be.message)
def create_menu_item(icon_name, icon_color, label, tag, coords, screen_branding, static_flow, is_broadcast_settings,
                     broadcast_branding, requires_wifi, run_in_background, roles):
    from rogerthat.bizz.service import create_menu_item as create_menu_item_bizz
    service_user = users.get_current_user()
    try:
        create_menu_item_bizz(service_user, icon_name, icon_color, label, tag, coords, screen_branding, static_flow,
                              requires_wifi, run_in_background, roles, is_broadcast_settings, broadcast_branding)
        return RETURNSTATUS_TO_SUCCESS
    except InvalidValueException, e:
        return ReturnStatusTO.create(False, e.fields.get('reason') or e.message)
Beispiel #32
0
def hints_mark_as_read(hint_id):
    service_user = users.get_current_user()
    try:
        solution_hint_settings = get_solution_hint_settings(service_user)
        if hint_id not in solution_hint_settings.do_not_show_again:
            solution_hint_settings.do_not_show_again.append(hint_id)
            solution_hint_settings.put()

        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
def branding_editor_save(description, color_scheme, background_color, text_color, menu_item_color, show_header,
                         static_content_mode, static_content, use_uploaded_logo):
    try:
        branding = generate_branding(users.get_current_user(), description, color_scheme, background_color or None,
                                     text_color or None, menu_item_color or None, show_header, static_content_mode,
                                     static_content, use_uploaded_logo)
        logging.debug("Generated branding: %s" % branding.key().name())
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, be:
        logging.exception("Failed to generate branding with branding designer")
        return ReturnStatusTO.create(False, "Failed to create branding (%s)" % be.message)
Beispiel #34
0
def customer_signup(city_customer_id, company, customer, recaptcha_token):
    try:
        create_customer_signup(
            city_customer_id,
            company,
            customer,
            recaptcha_token,
            domain=get_current_http_host(with_protocol=True),
            accept_missing=True)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException as e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #35
0
def save_cityapp_settings(gather_events,
                          uitdatabank_secret=None,
                          uitdatabank_key=None,
                          uitdatabank_regions=None):
    from solutions.common.bizz.cityapp import save_cityapp_settings as save_cityapp_settings_bizz
    try:
        service_user = users.get_current_user()
        save_cityapp_settings_bizz(service_user, gather_events,
                                   uitdatabank_secret, uitdatabank_key,
                                   uitdatabank_regions or [])
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException as e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #36
0
def delete_holiday(holiday):
    from solutions.common.bizz.holiday import delete_holiday as delete_holiday_bizz
    service_user = users.get_current_user()
    session_ = users.get_current_session()
    service_identity = session_.service_identity
    try:
        delete_holiday_bizz(service_user, service_identity, holiday)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        sln_settings = get_solution_settings(service_user)
        return ReturnStatusTO.create(
            False,
            common_translate(sln_settings.main_language, SOLUTION_COMMON,
                             e.message))
Beispiel #37
0
def save_out_of_office_message(message):
    from solutions.common.bizz.holiday import save_out_of_office_message as save_oof_message
    service_user = users.get_current_user()
    session_ = users.get_current_session()
    service_identity = session_.service_identity
    try:
        save_oof_message(service_user, service_identity, message)
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        sln_settings = get_solution_settings(service_user)
        return ReturnStatusTO.create(
            False,
            common_translate(sln_settings.main_language, SOLUTION_COMMON,
                             e.message))
Beispiel #38
0
def close_city_wide_lottery_info(key):
    service_user = users.get_current_user()
    try:
        ll_info = SolutionCityWideLottery.get(key)
        if ll_info and not ll_info.pending and not ll_info.deleted:
            ll_info.deleted = True
            ll_info.put()

        send_message(service_user, u"solutions.common.loyalty.lottery.update",
                     service_identity=ll_info.service_identity)

        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        sln_settings = get_solution_settings(service_user)
        return ReturnStatusTO.create(False, common_translate(sln_settings.main_language, SOLUTION_COMMON, e.message))
Beispiel #39
0
def get_service(service_email):
    city_service_user = users.get_current_user()
    city_customer = get_customer(city_service_user)
    service_user = users.User(email=service_email)
    customer = Customer.get_by_service_email(service_email)
    if not city_customer.can_edit_service(customer):
        logging.warn(u'Service %s tried to save service information for customer %d', city_service_user, customer.id)
        lang = get_solution_settings(city_service_user).main_language
        return ReturnStatusTO.create(False, translate(lang, SOLUTION_COMMON, 'no_permission'))
    contact = Contact.get_one(customer.key())
    solution_settings = get_solution_settings(service_user)
    return ServiceTO(customer.id, customer.name, customer.address1, customer.address2, customer.zip_code, customer.city,
                     customer.user_email, contact.phone_number, solution_settings.main_language,
                     solution_settings.modules, solution_settings.broadcast_types, customer.organization_type,
                     customer.vat, customer.website, customer.facebook_page)
Beispiel #40
0
def rest_delete_service(service_email):
    city_service_user = users.get_current_user()
    city_customer = get_customer(city_service_user)
    customer = Customer.get_by_service_email(service_email)
    if not city_customer.can_edit_service(customer):
        lang = get_solution_settings(city_service_user).main_language
        logging.warn(u'Service %s tried to save service information for customer %d', city_service_user, customer.id)
        return ReturnStatusTO.create(False, translate(lang, SOLUTION_COMMON, 'no_permission'))
    cancel_subscription(customer.id, Customer.DISABLED_REASONS[Customer.DISABLED_ASSOCIATION_BY_CITY], True)
    session = users.get_current_session()
    service_identity = session.service_identity
    send_message_to_session(city_service_user, session,
                            [{u"type": u"solutions.common.services.deleted",
                              u'service_email': service_email,
                              u'service_organization_type': customer.organization_type}],
                            si=service_identity)
    return RETURNSTATUS_TO_SUCCESS
Beispiel #41
0
def delete_city_wide_lottery_info(key):
    ll_info_delete = SolutionCityWideLottery.get(key)
    if not ll_info_delete:
        return RETURNSTATUS_TO_SUCCESS

    service_user = users.get_current_user()
    sln_settings = get_solution_settings(service_user)

    try:
        ll_info = SolutionCityWideLottery.load_pending(ll_info_delete.app_id)
        if ll_info_delete.key() == ll_info.key():
            raise RETURNSTATUS_TO_SUCCESS
        if ll_info_delete.schedule_loot_time > 0:
            ll_info_delete.delete()

        send_message(service_user, u"solutions.common.loyalty.lottery.update")

        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, common_translate(sln_settings.main_language, SOLUTION_COMMON, e.message))
Beispiel #42
0
def put_loyalty_settings(loyalty_type, loyalty_settings, loyalty_website):
    service_user = users.get_current_user()
    try:
        def trans(loyalty_type):
            sln_settings = get_solution_settings(service_user)
            if SolutionModule.HIDDEN_CITY_WIDE_LOTTERY in sln_settings.modules:
                loyalty_type = SolutionLoyaltySettings.LOYALTY_TYPE_CITY_WIDE_LOTTERY
            sln_settings.updates_pending = True

            sln_loyalty_settings = SolutionLoyaltySettings.get_by_user(service_user)

            if sln_loyalty_settings.loyalty_type != loyalty_type:
                sln_loyalty_settings.branding_key = None
                sln_settings.loyalty_branding_hash = None
                sln_loyalty_settings.loyalty_type = loyalty_type

            if sln_loyalty_settings.website != loyalty_website:
                sln_loyalty_settings.modification_time = now()

            sln_loyalty_settings.website = loyalty_website

            if loyalty_type == SolutionLoyaltySettings.LOYALTY_TYPE_REVENUE_DISCOUNT:
                sln_loyalty_settings.x_visits = loyalty_settings.x_visits
                sln_loyalty_settings.x_discount = loyalty_settings.x_discount
            elif loyalty_type == SolutionLoyaltySettings.LOYALTY_TYPE_STAMPS:
                sln_loyalty_settings.x_stamps = loyalty_settings.x_stamps
                sln_loyalty_settings.stamps_type = loyalty_settings.stamps_type
                sln_loyalty_settings.stamps_winnings = loyalty_settings.stamps_winnings
                sln_loyalty_settings.stamps_auto_redeem = loyalty_settings.stamps_auto_redeem

            put_and_invalidate_cache(sln_loyalty_settings, sln_settings)
            return sln_settings

        xg_on = db.create_transaction_options(xg=True)
        sln_settings = db.run_in_transaction_options(xg_on, trans, loyalty_type)
        broadcast_updates_pending(sln_settings)

        send_message(service_user, u"solutions.common.loyalty.settings.update")
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        return ReturnStatusTO.create(False, e.message)
Beispiel #43
0
def add_loyalty_scan(key, loyalty_type, value):
    service_user = users.get_current_user()
    try:
        sls = SolutionLoyaltyScan.get(key)
        if sls is None:
            raise BusinessException("Could not find scan")
        if sls.processed:
            raise BusinessException("Scan was already processed")

        if sls.app_user_info:
            user_details = UserDetailsTO()
            user_details.email = sls.app_user_info.email
            user_details.name = sls.app_user_info.name
            user_details.language = sls.app_user_info.language
            user_details.avatar_url = sls.app_user_info.avatar_url
            user_details.app_id = sls.app_user_info.app_id
        else:
            # XXX: don't use get_profile_infos
            profile_info = get_profile_infos([sls.app_user], allow_none_in_results=True)[0]
            if not profile_info or profile_info.isServiceIdentity:
                user_details = None
            else:
                user_details = UserDetailsTO.fromUserProfile(profile_info)

        jsondata = {}
        jsondata['loyalty_type'] = loyalty_type
        if loyalty_type == SolutionLoyaltySettings.LOYALTY_TYPE_REVENUE_DISCOUNT:
            jsondata['price'] = value
        else:
            jsondata['count'] = value
        success, _, _ = add_loyalty_for_user(
            service_user, sls.service_identity, sls.admin_user, sls.app_user, jsondata, now(), user_details)
        if not success:
            raise BusinessException("error-occured-unknown")

        sls.processed = True
        sls.put()
        return RETURNSTATUS_TO_SUCCESS
    except BusinessException, e:
        sln_settings = get_solution_settings(service_user)
        return ReturnStatusTO.create(False, common_translate(sln_settings.main_language, SOLUTION_COMMON, e.message))
           run_in_background=bool, roles=[(int, long)], link=ServiceMenuItemLinkTO, fall_through=bool,
           form_id=(int, long, NoneType))
def create_menu_item(icon_name, icon_color, label, tag, coords, screen_branding, static_flow, is_broadcast_settings,
                     broadcast_branding, requires_wifi, run_in_background, roles, link=None, fall_through=False,
                     form_id=None):
    from rogerthat.bizz.service import create_menu_item as create_menu_item_bizz
    service_user = users.get_current_user()
    try:
        create_menu_item_bizz(service_user, icon_name, icon_color, label, tag, coords, screen_branding, static_flow,
                              requires_wifi, run_in_background, roles, is_broadcast_settings, broadcast_branding,
                              link=link, fall_through=fall_through, form_id=form_id)
        return RETURNSTATUS_TO_SUCCESS
    except InvalidValueException, e:
        return ReturnStatusTO.create(False, e.fields.get('reason') or e.message)
    except BusinessException, be:
        return ReturnStatusTO.create(False, be.message)


@rest("/mobi/rest/service/menu/move", "post")
@returns(NoneType)
@arguments(source_coords=[int], target_coords=[int])
def move_menu_item(source_coords, target_coords):
    from rogerthat.bizz.service import move_menu_item as move_menu_item_bizz
    service_user = users.get_current_user()
    move_menu_item_bizz(service_user, source_coords, target_coords)


@rest("/mobi/rest/service/menu/delete", "post")
@returns(NoneType)
@arguments(coords=[int])
def delete_menu_item(coords):
Beispiel #45
0
def rest_save_translations(app_id, translations):
    trans = AppTranslations.get(AppTranslations.create_key(app_id))
    trans.translations = zlib.compress(translations.encode('utf-8'))
    put_and_invalidate_cache(trans)
    return ReturnStatusTO.create(True, None)