(self, instance, cases=None)
return "\n\n".join(messages)
Formplayer requests get a detailed success message pointing to the form/case affected.
        All other requests get a generic message.

        Message is formatted with markdown.
Formplayer requests get a detailed success message pointing to the form/case affected.
        All other requests get a generic message.
Formplayer requests get a detailed success message pointing to the form / case affected . All other requests get a generic message .
def _get_success_message(self, instance, cases=None):
        '''
        Formplayer requests get a detailed success message pointing to the form/case affected.
        All other requests get a generic message.

        Message is formatted with markdown.
        '''

        if not instance.metadata or instance.metadata.deviceID != FORMPLAYER_DEVICE_ID:
            return '   √   '

        messages = []
        user = CouchUser.get_by_user_id(instance.user_id)
        if not user or not user.is_web_user():
            return _('Form successfully saved!')

        from corehq.apps.export.views.list import CaseExportListView, FormExportListView
        from corehq.apps.export.views.utils import can_view_case_exports, can_view_form_exports
        from corehq.apps.reports.views import CaseDataView, FormDataView
        form_link = case_link = form_export_link = case_export_link = None
        form_view = 'corehq.apps.reports.standard.inspect.SubmitHistory'
        if has_permission_to_view_report(user, instance.domain, form_view):
            form_link = reverse(FormDataView.urlname, args=[instance.domain, instance.form_id])
        case_view = 'corehq.apps.reports.standard.cases.basic.CaseListReport'
        if cases and has_permission_to_view_report(user, instance.domain, case_view):
            if len(cases) == 1:
                case_link = reverse(CaseDataView.urlname, args=[instance.domain, cases[0].case_id])
            else:
                case_link = ", ".join(["[{}]({})".format(
                    c.name, reverse(CaseDataView.urlname, args=[instance.domain, c.case_id])
                ) for c in cases])
        if can_view_form_exports(user, instance.domain):
            form_export_link = reverse(FormExportListView.urlname, args=[instance.domain])
        if cases and can_view_case_exports(user, instance.domain):
            case_export_link = reverse(CaseExportListView.urlname, args=[instance.domain])

        # Start with generic message
        messages.append(_('Form successfully saved!'))

        # Add link to form/case if possible
        if form_link and case_link:
            if len(cases) == 1:
                messages.append(
                    _("You submitted [this form]({}), which affected [this case]({}).")
                    .format(form_link, case_link))
            else:
                messages.append(
                    _("You submitted [this form]({}), which affected these cases: {}.")
                    .format(form_link, case_link))
        elif form_link:
            messages.append(_("You submitted [this form]({}).").format(form_link))
        elif case_link:
            if len(cases) == 1:
                messages.append(_("Your form affected [this case]({}).").format(case_link))
            else:
                messages.append(_("Your form affected these cases: {}.").format(case_link))

        # Add link to all form/case exports
        if form_export_link and case_export_link:
            messages.append(
                _("Click to export your [case]({}) or [form]({}) data.")
                .format(case_export_link, form_export_link))
        elif form_export_link:
            messages.append(_("Click to export your [form data]({}).").format(form_export_link))
        elif case_export_link:
            messages.append(_("Click to export your [case data]({}).").format(case_export_link))

        return "\n\n".join(messages)
def _get_success_message ( self , instance , cases = None ) : if not instance . metadata or instance . metadata . deviceID != FORMPLAYER_DEVICE_ID : return '   √   ' messages = [ ] user = CouchUser . get_by_user_id ( instance . user_id ) if not user or not user . is_web_user ( ) : return _ ( 'Form successfully saved!' ) from corehq . apps . export . views . list import CaseExportListView , FormExportListView from corehq . apps . export . views . utils import can_view_case_exports , can_view_form_exports from corehq . apps . reports . views import CaseDataView , FormDataView form_link = case_link = form_export_link = case_export_link = None form_view = 'corehq.apps.reports.standard.inspect.SubmitHistory' if has_permission_to_view_report ( user , instance . domain , form_view ) : form_link = reverse ( FormDataView . urlname , args = [ instance . domain , instance . form_id ] ) case_view = 'corehq.apps.reports.standard.cases.basic.CaseListReport' if cases and has_permission_to_view_report ( user , instance . domain , case_view ) : if len ( cases ) == 1 : case_link = reverse ( CaseDataView . urlname , args = [ instance . domain , cases [ 0 ] . case_id ] ) else : case_link = ", " . join ( [ "[{}]({})" . format ( c . name , reverse ( CaseDataView . urlname , args = [ instance . domain , c . case_id ] ) ) for c in cases ] ) if can_view_form_exports ( user , instance . domain ) : form_export_link = reverse ( FormExportListView . urlname , args = [ instance . domain ] ) if cases and can_view_case_exports ( user , instance . domain ) : case_export_link = reverse ( CaseExportListView . urlname , args = [ instance . domain ] ) # Start with generic message messages . append ( _ ( 'Form successfully saved!' ) ) # Add link to form/case if possible if form_link and case_link : if len ( cases ) == 1 : messages . append ( _ ( "You submitted [this form]({}), which affected [this case]({})." ) . format ( form_link , case_link ) ) else : messages . append ( _ ( "You submitted [this form]({}), which affected these cases: {}." ) . format ( form_link , case_link ) ) elif form_link : messages . append ( _ ( "You submitted [this form]({})." ) . format ( form_link ) ) elif case_link : if len ( cases ) == 1 : messages . append ( _ ( "Your form affected [this case]({})." ) . format ( case_link ) ) else : messages . append ( _ ( "Your form affected these cases: {}." ) . format ( case_link ) ) # Add link to all form/case exports if form_export_link and case_export_link : messages . append ( _ ( "Click to export your [case]({}) or [form]({}) data." ) . format ( case_export_link , form_export_link ) ) elif form_export_link : messages . append ( _ ( "Click to export your [form data]({})." ) . format ( form_export_link ) ) elif case_export_link : messages . append ( _ ( "Click to export your [case data]({})." ) . format ( case_export_link ) ) return "\n\n" . join ( messages )