Exemplo n.º 1
0
def merge_steps(flow_run, new_steps):
    # In case of sub flows, new_steps won't contain steps from the previous flow.
    steps = parse_complex_value(object_factory('step_type', FLOW_STEP_MAPPING),
                                flow_run.steps, True)
    saved_step_ids = [step.step_id for step in steps]
    for step in new_steps:
        if step.step_id not in saved_step_ids:
            steps.append(step)
    return steps
Exemplo n.º 2
0
def flow_member_result(rt_settings, request_id, message_flow_run_id, member,
                       steps, end_id, end_message_flow_id, parent_message_key,
                       tag, result_key, flush_id, flush_message_flow_id,
                       service_identity, user_details, flow_params, **kwargs):
    user_details = log_and_parse_user_details(user_details)
    steps = parse_complex_value(object_factory("step_type", FLOW_STEP_MAPPING),
                                steps, True)

    f = FMR_TAG_MAPPING.get(parse_to_human_readable_tag(tag))
    if not f:
        logging.info('[tff] Ignoring flow_member_result with tag %s', tag)
        return None

    result = f(message_flow_run_id, member, steps, end_id, end_message_flow_id,
               parent_message_key, tag, result_key, flush_id,
               flush_message_flow_id, service_identity, user_details,
               flow_params)

    return result and serialize_complex_value(
        result, FlowMemberResultCallbackResultTO, False, skip_missing=True)
Exemplo n.º 3
0
def flow_member_result(rt_settings, request_id, message_flow_run_id, member, steps, end_id, end_message_flow_id,
                       parent_message_key, tag, result_key, flush_id, flush_message_flow_id, service_identity,
                       user_details, flow_params, timestamp, **kwargs):
    user_details = log_and_parse_user_details(user_details)
    steps = parse_complex_value(object_factory("step_type", FLOW_STEP_MAPPING), steps, True)

    f = FMR_TAG_MAPPING.get(parse_to_human_readable_tag(tag))
    should_process_flush = f and not flush_id.startswith('flush_monitoring')

    result = None
    try:
        if should_process_flush:
            logging.info('Processing flow_member_result with tag %s and flush_id %s', tag, flush_id)
            result = f(message_flow_run_id, member, steps, end_id, end_message_flow_id, parent_message_key, tag,
                       result_key, flush_id, flush_message_flow_id, service_identity, user_details, flow_params)
            return result and serialize_complex_value(result, FlowMemberResultCallbackResultTO, False,
                                                      skip_missing=True)
        else:
            logging.info('[tff] Ignoring flow_member_result with tag %s and flush_id %s', tag, flush_id)
    finally:
        deferred.defer(save_flow_statistics, parent_message_key, steps, end_id, tag, flush_id, flush_message_flow_id,
                       user_details[0], timestamp, result)
                     force_language=None, download_attachments_upfront=False, push_message=None, flow=None,
                     flow_params=None):
    from rogerthat.bizz.service.mfr import start_local_flow as start_local_flow_bizz
    from rogerthat.bizz.service import get_and_validate_service_identity_user
    service_identity_user = get_and_validate_service_identity_user(users.get_current_user(), service_identity)

    mm = _convert_to_member_users(service_identity_user, members)
    return start_local_flow_bizz(service_identity_user, parent_message_key, xml, mm, tag, context, force_language,
                                 download_attachments_upfront, push_message, None, flow, flow_params)

#############################################
# DO NOT DOCUMENT THIS SERVICE API FUNCTION #
# MFR ONLY                                  #
@service_api(function=u"messaging.mfr_flow_member_result")
@returns(NoneType)
@arguments(message_flow_run_id=unicode, member=unicode, steps=[object_factory("step_type", FLOW_STEP_MAPPING)],
           end_id=unicode, flush_id=unicode, parent_message_key=unicode, service_identity=unicode, results_email=bool,
           email_admins=bool, emails=[unicode], message_flow_name=unicode, app_id=unicode)
def mfr_flow_member_result(message_flow_run_id, member, steps, end_id, flush_id, parent_message_key,
                           service_identity=None, results_email=False, email_admins=False, emails=None,
                           message_flow_name=None, app_id=None):
    from rogerthat.bizz.service import get_and_validate_app_id_for_service_identity_user
    svc_user = get_current_user()
    azzert(svc_user.is_mfr)

    if not service_identity or service_identity == MISSING:
        service_identity = ServiceIdentity.DEFAULT

    mfr = get_message_flow_run_record(svc_user, message_flow_run_id)
    if not mfr:
        return
Exemplo n.º 5
0
from solutions.common.models.order import SolutionOrder, SolutionOrderWeekdayTimeframe
from solutions.common.models.properties import SolutionUser
from solutions.common.to import SolutionInboxMessageTO
from solutions.common.utils import create_service_identity_user_wo_default

try:
    from cStringIO import StringIO
except ImportError:
    from cStringIO import StringIO


@returns()
@arguments(service_user=users.User,
           message_flow_run_id=unicode,
           member=unicode,
           steps=[object_factory("step_type", FLOW_STEP_MAPPING)],
           end_id=unicode,
           end_message_flow_id=unicode,
           parent_message_key=unicode,
           tag=unicode,
           result_key=unicode,
           flush_id=unicode,
           flush_message_flow_id=unicode,
           service_identity=unicode,
           user_details=[UserDetailsTO])
def _order_received(service_user, message_flow_run_id, member, steps, end_id,
                    end_message_flow_id, parent_message_key, tag, result_key,
                    flush_id, flush_message_flow_id, service_identity,
                    user_details):

    from solutions.common.bizz.messaging import send_inbox_forwarders_message
Exemplo n.º 6
0
from solutions.common.bizz.loyalty import update_user_data_admins
from solutions.common.dal import get_solution_settings, get_solution_main_branding, \
    get_solution_settings_or_identity_settings
from solutions.common.exceptions.sandwich import InvalidSandwichSettingsException
from solutions.common.models import SolutionInboxMessage
from solutions.common.models.properties import SolutionUser
from solutions.common.models.sandwich import SandwichType, SandwichTopping, \
    SandwichOrder, SandwichOption, SandwichSettings
from solutions.common.to import SolutionInboxMessageTO
from solutions.common.utils import create_service_identity_user_wo_default
from solutions.flex import SOLUTION_FLEX


@returns(FlowMemberResultCallbackResultTO)
@arguments(service_user=users.User, message_flow_run_id=unicode, member=unicode,
           steps=[object_factory("step_type", FLOW_STEP_MAPPING)], end_id=unicode, end_message_flow_id=unicode,
           parent_message_key=unicode, tag=unicode, result_key=unicode, flush_id=unicode, flush_message_flow_id=unicode,
           service_identity=unicode, user_details=[UserDetailsTO])
def order_sandwich_received(service_user, message_flow_run_id, member, steps, end_id, end_message_flow_id, parent_message_key,
                   tag, result_key, flush_id, flush_message_flow_id, service_identity, user_details):
    type_ = get_first_fmr_step_result_value(steps, u'message_type')
    topping = get_first_fmr_step_result_value(steps, u'message_topping')
    customizations = get_first_fmr_step_result_value(steps, u'message_customize')
    remark = get_first_fmr_step_result_value(steps, u'message_remark')
    takeaway_time = get_first_fmr_step_result_value(steps, u'message_takeaway_time')

    deferred.defer(process_sandwich_order, service_user, service_identity, user_details, type_, topping, customizations,
                   remark, takeaway_time, parent_message_key)

    sln_settings = get_solution_settings(service_user)
    main_branding = get_solution_main_branding(service_user)
Exemplo n.º 7
0
from plugins.tff_backend.bizz.email import send_emails_to_support
from plugins.tff_backend.bizz.iyo.utils import get_iyo_username
from plugins.tff_backend.bizz.kyc import save_utility_bill, validate_kyc_status
from plugins.tff_backend.bizz.kyc.onfido_bizz import update_applicant, create_applicant, upload_document
from plugins.tff_backend.bizz.rogerthat import create_error_message
from plugins.tff_backend.bizz.user import get_tff_profile, generate_kyc_flow, set_kyc_status
from plugins.tff_backend.models.user import KYCStatus
from plugins.tff_backend.plugin_consts import KYC_FLOW_PART_2_TAG, SCHEDULED_QUEUE
from plugins.tff_backend.to.user import SetKYCPayloadTO
from plugins.tff_backend.utils import get_step


@returns(FlowMemberResultCallbackResultTO)
@arguments(message_flow_run_id=unicode,
           member=unicode,
           steps=[object_factory('step_type', FLOW_STEP_MAPPING)],
           end_id=unicode,
           end_message_flow_id=unicode,
           parent_message_key=unicode,
           tag=unicode,
           result_key=unicode,
           flush_id=unicode,
           flush_message_flow_id=unicode,
           service_identity=unicode,
           user_details=[UserDetailsTO],
           flow_params=unicode)
def kyc_part_1(message_flow_run_id, member, steps, end_id, end_message_flow_id,
               parent_message_key, tag, result_key, flush_id,
               flush_message_flow_id, service_identity, user_details,
               flow_params):
    iyo_username = get_iyo_username(user_details[0])
Exemplo n.º 8
0
    FLOW_HOSTER_REMINDER, SCHEDULED_QUEUE, FLOW_UTILITY_BILL_RECEIVED, FF_ENDED_TIMESTAMP
from plugins.tff_backend.to.investor import InvestmentAgreementTO, InvestmentAgreementDetailsTO, \
    CreateInvestmentAgreementTO
from plugins.tff_backend.utils import get_step_value, round_currency_amount, get_key_name_from_key_string, get_step
from plugins.tff_backend.utils.app import create_app_user_by_email, get_app_user_tuple

INVESTMENT_TODO_MAPPING = {
    InvestmentAgreement.STATUS_CANCELED: None,
    InvestmentAgreement.STATUS_CREATED: InvestorSteps.FLOW_AMOUNT,
    InvestmentAgreement.STATUS_SIGNED: InvestorSteps.PAY,
    InvestmentAgreement.STATUS_PAID: InvestorSteps.ASSIGN_TOKENS,
}


@returns(FlowMemberResultCallbackResultTO)
@arguments(message_flow_run_id=unicode, member=unicode, steps=[object_factory("step_type", FLOW_STEP_MAPPING)],
           end_id=unicode, end_message_flow_id=unicode, parent_message_key=unicode, tag=unicode, result_key=unicode,
           flush_id=unicode, flush_message_flow_id=unicode, service_identity=unicode, user_details=[UserDetailsTO],
           flow_params=unicode)
def invest_tft(message_flow_run_id, member, steps, end_id, end_message_flow_id, parent_message_key, tag, result_key,
               flush_id, flush_message_flow_id, service_identity, user_details, flow_params):
    return invest(message_flow_run_id, member, steps, end_id, end_message_flow_id, parent_message_key, tag, result_key,
                  flush_id, flush_message_flow_id, service_identity, user_details, flow_params, TOKEN_TFT)


@returns(FlowMemberResultCallbackResultTO)
@arguments(message_flow_run_id=unicode, member=unicode, steps=[object_factory("step_type", FLOW_STEP_MAPPING)],
           end_id=unicode, end_message_flow_id=unicode, parent_message_key=unicode, tag=unicode, result_key=unicode,
           flush_id=unicode, flush_message_flow_id=unicode, service_identity=unicode, user_details=[UserDetailsTO],
           flow_params=unicode)
def invest_itft(message_flow_run_id, member, steps, end_id, end_message_flow_id, parent_message_key, tag, result_key,
    from rogerthat.bizz.messaging import message_received
    message_received(user, get_message_key(request.message_key, request.message_parent_key), request.received_timestamp)

@rest("/mobi/rest/messaging/get", "get")
@returns(RootMessageListTO)
@arguments(cursor=unicode)
def getMessages(cursor):
    from rogerthat.rpc import users
    user = users.get_current_user()
    result = RootMessageListTO()
    result.messages, result.cursor = _get_messages(cursor, user)
    result.batch_size = MESSAGES_BATCH_SIZE
    return result

@rest("/mobi/rest/messaging/get_single", "post")
@returns(object_factory("message_type", MESSAGE_TYPE_TO_MAPPING))
@arguments(message_key=unicode, parent_message_key=unicode)
def getSingleMessage(message_key, parent_message_key):
    from rogerthat.rpc import users
    user = users.get_current_user()
    message = get_message(message_key, parent_message_key)
    return _convert_to_tos(user, [message])[0]

@rest("/mobi/rest/messaging/get_root_message", "get")
@returns(object_factory("message_type", ROOT_MESSAGE_TYPE_TO_MAPPING))
@arguments(message_key=unicode)
def getRootMessage(message_key):
    from rogerthat.rpc import users
    user = users.get_current_user()
    messages = get_root_message(user, message_key)
    member = user if not messages[0].sharedMembers and messages[0].sender != user else None
Exemplo n.º 10
0
    def trans():
        sln_l_settings = SolutionLoyaltySettings.get_by_user(service_user)
        if is_default_service_identity(service_identity):
            sln_li_settings = sln_l_settings
        else:
            sln_li_settings = SolutionLoyaltyIdentitySettings.get_by_user(service_user, service_identity)
        return sln_l_settings, sln_li_settings
    xg_on = db.create_transaction_options(xg=True)
    sln_l_settings, sln_li_settings = db.run_in_transaction_options(xg_on, trans)
    return LoyaltySettingsTO.fromSolutionLoyaltySettingsObject(sln_l_settings, sln_li_settings, loyalty_type) if sln_l_settings else None


@rest("/common/loyalty/settings/put", "post")
@returns(ReturnStatusTO)
@arguments(loyalty_type=(int, long), loyalty_settings=object_factory("loyalty_type", LOYALTY_SETTINGS_MAPPING), loyalty_website=unicode)
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
Exemplo n.º 11
0
    while True:
        if z == 0:
            start_y = 1
        else:
            start_y = 0
        for y in range(start_y, 3):
            for x in range(start_x, 4):
                if [x, y, z] not in all_taken_coords:
                    spots_to_get = spots_to_get - 1
                    spots.append([x, y, z])
                    if not spots_to_get > 0:
                        return spots
        z += 1


@arguments(steps=[object_factory("step_type", FLOW_STEP_MAPPING)],
           step_id=unicode)
def get_first_fmr_step_result_value(steps, step_id):
    for step in steps:
        if step.step_id == step_id:
            return step.get_value()
    return None


@returns(unicode)
@arguments(src=unicode, path=unicode, default_css=unicode)
def create_pdf(src, path, default_css=None):
    """

    Args:
        src: The source to be parsed. This can be a file handle or a String - or even better - a Unicode object.