Example #1
0
    def create_default_app_strings(self, app, build_profile_id=None):
        messages = {}

        langs = app.get_build_langs(build_profile_id)
        for lc in reversed(langs):
            if lc == "default":
                continue
            new_messages = commcare_translations.loads(
                self.create_app_strings(app, lc, for_default=True))

            for key, val in new_messages.items():
                # do not overwrite a real trans with a blank trans
                if not (val == '' and key in messages):
                    messages[key] = val

        if 'case_sharing.exactly_one_group' not in messages:
            messages['case_sharing.exactly_one_group'] = \
                ('The case sharing settings for your user are incorrect. '
                 'This user must be in exactly one case sharing group. Please contact your supervisor.')

        if 'case_autoload.fixture.exactly_one_fixture' not in messages:
            messages['case_autoload.fixture.exactly_one_fixture'] = \
                ('The lookup table settings for your user are incorrect. '
                    'This user must have access to exactly one lookup table row for the table: ${0}')

        if 'case_autoload.usercase.case_missing' not in messages:
            messages['usercase.missing_id'] = \
                ('This form affects the user case, but no user case id was found. '
                    'Please contact your supervisor.')

        from corehq.apps.app_manager.models import (
            AUTO_SELECT_CASE, AUTO_SELECT_FIXTURE, AUTO_SELECT_USER,
            AUTO_SELECT_LOCATION, AUTO_SELECT_USERCASE, AUTO_SELECT_RAW)

        mode_text = {
            AUTO_SELECT_FIXTURE: 'lookup table field',
            AUTO_SELECT_USER: '******',
            AUTO_SELECT_CASE: 'case index',
            AUTO_SELECT_USERCASE: 'user case',
            AUTO_SELECT_RAW: 'custom xpath expression',
        }

        for mode, text in mode_text.items():
            key = 'case_autoload.{0}.property_missing'.format(mode)
            if key not in messages:
                messages[key] = ('The {} specified for case auto-selecting '
                                 'could not be found: ${{0}}').format(text)
            key = 'case_autoload.{0}.case_missing'.format(mode)
            if key not in messages:
                messages[
                    key] = 'Unable to find case referenced by auto-select case ID.'

        key = 'case_autoload.{0}.property_missing'.format(AUTO_SELECT_LOCATION)
        messages[key] = ("This form requires access to the user's location, "
                         "but none was found.")
        key = 'case_autoload.{0}.case_missing'.format(AUTO_SELECT_LOCATION)
        messages[key] = ("This form requires the user's location to be "
                         "marked as 'Tracks Stock'.")

        return commcare_translations.dumps(messages).encode('utf-8')
Example #2
0
    def create_default_app_strings(self, app, build_profile_id=None):
        messages = {}

        langs = app.get_build_langs(build_profile_id)
        for lc in reversed(langs):
            if lc == "default":
                continue
            new_messages = commcare_translations.loads(
                self.create_app_strings(app, lc, for_default=True)
            )

            for key, val in new_messages.items():
                # do not overwrite a real trans with a blank trans
                if not (val == '' and key in messages):
                    messages[key] = val

        if 'case_sharing.exactly_one_group' not in messages:
            messages['case_sharing.exactly_one_group'] = \
                (u'The case sharing settings for your user are incorrect. '
                 u'This user must be in exactly one case sharing group. Please contact your supervisor.')

        if 'case_autoload.fixture.exactly_one_fixture' not in messages:
            messages['case_autoload.fixture.exactly_one_fixture'] = \
                (u'The lookup table settings for your user are incorrect. '
                    u'This user must have access to exactly one lookup table row for the table: ${0}')

        from corehq.apps.app_manager.models import (
            AUTO_SELECT_CASE, AUTO_SELECT_FIXTURE, AUTO_SELECT_USER,
            AUTO_SELECT_LOCATION, AUTO_SELECT_USERCASE, AUTO_SELECT_RAW
        )

        mode_text = {
            AUTO_SELECT_FIXTURE: u'lookup table field',
            AUTO_SELECT_USER: u'user data key',
            AUTO_SELECT_CASE: u'case index',
            AUTO_SELECT_USERCASE: u'user case',
            AUTO_SELECT_RAW: u'custom xpath expression',
        }

        for mode, text in mode_text.items():
            key = 'case_autoload.{0}.property_missing'.format(mode)
            if key not in messages:
                messages[key] = (u'The {} specified for case auto-selecting '
                                 u'could not be found: ${{0}}').format(text)
            key = 'case_autoload.{0}.case_missing'.format(mode)
            if key not in messages:
                messages[key] = u'Unable to find case referenced by auto-select case ID.'

        key = 'case_autoload.{0}.property_missing'.format(AUTO_SELECT_LOCATION)
        messages[key] = (u"This form requires access to the user's location, "
                         "but none was found.")
        key = 'case_autoload.{0}.case_missing'.format(AUTO_SELECT_LOCATION)
        messages[key] = (u"This form requires the user's location to be "
                         "marked as 'Tracks Stock'.")

        return commcare_translations.dumps(messages).encode('utf-8')
Example #3
0
 def create_app_strings(self,
                        app,
                        lang,
                        for_default=False,
                        build_profile_id=None):
     # build_profile_id is relevant only if for_default is true
     messages = {}
     for part in self.app_strings_parts(app,
                                        lang,
                                        for_default=for_default,
                                        build_profile_id=build_profile_id):
         messages.update(part)
     return commcare_translations.dumps(messages)
Example #4
0
    def create_default_app_strings(self, app):
        messages = {}

        for lc in reversed(app.langs):
            if lc == "default":
                continue
            new_messages = commcare_translations.loads(
                self.create_app_strings(app, lc, for_default=True)
            )

            for key, val in new_messages.items():
                # do not overwrite a real trans with a blank trans
                if not (val == '' and key in messages):
                    messages[key] = val

        if 'case_sharing.exactly_one_group' not in messages:
            messages['case_sharing.exactly_one_group'] = \
                (u'The case sharing settings for your user are incorrect. '
                 u'This user must be in exactly one case sharing group. Please contact your supervisor.')

        if 'case_autoload.fixture.exactly_one_fixture' not in messages:
            messages['case_autoload.fixture.exactly_one_fixture'] = \
                (u'The lookup table settings for your user are incorrect. '
                    u'This user must have access to exactly one lookup table row for the table: ${0}')

        from corehq.apps.app_manager.models import AUTO_SELECT_CASE, AUTO_SELECT_FIXTURE, AUTO_SELECT_USER

        mode_text = {
            AUTO_SELECT_FIXTURE: u'lookup table field',
            AUTO_SELECT_USER: u'user data key',
            AUTO_SELECT_CASE: u'case index'
        }

        for mode in [AUTO_SELECT_FIXTURE, AUTO_SELECT_CASE, AUTO_SELECT_USER]:
            key = 'case_autoload.{0}.property_missing'.format(mode)
            if key not in messages:
                messages[key] = (u'The {} specified for case auto-selecting '
                                 u'could not be found: ${{0}}').format(mode_text[mode])

        for mode in [AUTO_SELECT_FIXTURE, AUTO_SELECT_CASE, AUTO_SELECT_USER]:
            key = 'case_autoload.{0}.case_missing'.format(mode)
            if key not in messages:
                messages[key] = u'Unable to find case referenced by auto-select case ID.'

        return commcare_translations.dumps(messages).encode('utf-8')
Example #5
0
    def create_default_app_strings(self, app):
        messages = {}

        for lc in reversed(app.langs):
            if lc == "default":
                continue
            new_messages = commcare_translations.loads(
                self.create_app_strings(app, lc, for_default=True)
            )

            for key, val in new_messages.items():
                # do not overwrite a real trans with a blank trans
                if not (val == '' and key in messages):
                    messages[key] = val

        if 'case_sharing.exactly_one_group' not in messages:
            messages['case_sharing.exactly_one_group'] = \
                (u'The case sharing settings for your user are incorrect. '
                 u'This user must be in exactly one case sharing group. Please contact your supervisor.')

        if 'case_autoload.fixture.exactly_one_fixture' not in messages:
            messages['case_autoload.fixture.exactly_one_fixture'] = \
                (u'The lookup table settings for your user are incorrect. '
                    u'This user must have access to exactly one lookup table row for the table: ${0}')

        from corehq.apps.app_manager.models import AUTO_SELECT_CASE, AUTO_SELECT_FIXTURE, AUTO_SELECT_USER

        mode_text = {
            AUTO_SELECT_FIXTURE: u'lookup table field',
            AUTO_SELECT_USER: u'user data key',
            AUTO_SELECT_CASE: u'case index'
        }

        for mode in [AUTO_SELECT_FIXTURE, AUTO_SELECT_CASE, AUTO_SELECT_USER]:
            key = 'case_autoload.{0}.property_missing'.format(mode)
            if key not in messages:
                messages[key] = (u'The {} specified for case auto-selecting '
                                 u'could not be found: ${{0}}').format(mode_text[mode])

        for mode in [AUTO_SELECT_FIXTURE, AUTO_SELECT_CASE, AUTO_SELECT_USER]:
            key = 'case_autoload.{0}.case_missing'.format(mode)
            if key not in messages:
                messages[key] = u'Unable to find case referenced by auto-select case ID.'

        return commcare_translations.dumps(messages).encode('utf-8')
Example #6
0
    def create_default_app_strings(self, app):
        messages = {}

        for lc in reversed(app.langs):
            if lc == "default":
                continue
            new_messages = commcare_translations.loads(
                self.create_app_strings(app, lc, for_default=True)
            )

            for key, val in new_messages.items():
                # do not overwrite a real trans with a blank trans
                if not (val == '' and key in messages):
                    messages[key] = val

        if 'case_sharing.exactly_one_group' not in messages:
            messages['case_sharing.exactly_one_group'] = \
                u'Your phone is not set up properly for case sharing. Please contact your supervisor.'

        return commcare_translations.dumps(messages).encode('utf-8')
Example #7
0
    def create_default_app_strings(self, app):
        messages = {}

        for lc in reversed(app.langs):
            if lc == "default":
                continue
            new_messages = commcare_translations.loads(
                self.create_app_strings(app, lc, for_default=True)
            )

            for key, val in new_messages.items():
                # do not overwrite a real trans with a blank trans
                if not (val == '' and key in messages):
                    messages[key] = val

        if 'case_sharing.exactly_one_group' not in messages:
            messages['case_sharing.exactly_one_group'] = \
                (u'The case sharing settings for your user are incorrect. '
                 u'This user must be in exactly one case sharing group. Please contact your supervisor.')

        return commcare_translations.dumps(messages).encode('utf-8')
Example #8
0
 def create_app_strings(self, app, lang, for_default=False):
     messages = {}
     for part in self.app_strings_parts(app, lang, for_default=for_default):
         messages.update(part)
     return commcare_translations.dumps(messages).encode('utf-8')
Example #9
0
 def create_app_strings(self, app, lang, for_default=False):
     messages = {}
     for part in self.app_strings_parts(app, lang, for_default=for_default):
         messages.update(part)
     return commcare_translations.dumps(messages).encode('utf-8')