示例#1
0
    def test_ungrouped_in_non_english(self, urlretrieve_method):
        facility = self.facility
        params = {
            "zone_id": None,
            "facility_id": facility.id,
            "group_id": "Ungrouped"
        }
        test_zip_filepath = os.path.join(os.path.dirname(__file__), 'es.zip')
        urlretrieve_method.return_value = [test_zip_filepath, open(test_zip_filepath)]
        # Login as admin
        self.browser_login_admin()

        # Install the language pack
        if not "es" in get_installed_language_packs(force=True):
            call_command("languagepackdownload", lang_code="es")

        self.register_device()
        set_default_language("es")

        user = FacilityUser(username="******", facility=self.facility, group=None)
        user.set_password(raw_password="******")
        user.save()

        self.browse_to(self.reverse("group_management", kwargs=params))
        self.assertEqual(self.browser.find_element_by_xpath("//div[@id='groups']/div/dl/dd").text, "1", "Does not report one user for From Group.")        
示例#2
0
    def test_ungrouped_in_non_english(self, urlretrieve_method):
        facility = self.facility
        params = {
            "zone_id": None,
            "facility_id": facility.id,
            "group_id": "Ungrouped"
        }
        test_zip_filepath = os.path.join(os.path.dirname(__file__), 'es.zip')
        urlretrieve_method.return_value = [
            test_zip_filepath, open(test_zip_filepath)
        ]
        # Login as admin
        self.browser_login_admin()

        # Install the language pack
        if not "es" in get_installed_language_packs(force=True):
            call_command("languagepackdownload", lang_code="es")

        self.register_device()
        set_default_language("es")

        user = FacilityUser(username="******",
                            facility=self.facility,
                            group=None)
        user.set_password(raw_password="******")
        user.save()

        self.browse_to(self.reverse("group_management", kwargs=params))
        self.assertEqual(
            self.browser.find_element_by_xpath(
                "//div[@id='groups']/div/dl/dd").text, "1",
            "Does not report one user for From Group.")
示例#3
0
    def __init__(self, facility, admin_access=False, *args, **kwargs):
        super(FacilityUserForm, self).__init__(*args, **kwargs)

        self.admin_access = admin_access
        self.fields["default_language"].choices = [
            (lang_code, get_language_name(lang_code))
            for lang_code in get_installed_language_packs()
        ]

        # Select the initial default language,
        #   but only if we're not in the process of updating it to something else.
        if not self.fields[
                "default_language"].initial and "default_language" not in self.changed_data:
            self.fields["default_language"].initial = (
                self.instance
                and self.instance.default_language) or get_default_language()

        # Passwords only required on new, not on edit
        self.fields["password_first"].required = self.instance.pk == ""
        self.fields["password_recheck"].required = self.instance.pk == ""

        # Across POST and GET requests
        self.fields["zone_fallback"].initial = facility.get_zone()
        self.fields["facility"].initial = facility
        self.fields["facility"].queryset = Facility.objects.by_zone(
            facility.get_zone())
        self.fields["group"].queryset = FacilityGroup.objects.filter(
            facility=facility)
示例#4
0
def update_languages(request):
    # also refresh language choices here if ever updates js framework fails, but the language was downloaded anyway
    installed_languages = get_installed_language_packs(force=True)

    # here we want to reference the language meta data we've loaded into memory
    context = update_context(request)
    context.update({
        "installed_languages": installed_languages.values(),
    })
    return context
示例#5
0
def update_languages(request):
    # also refresh language choices here if ever updates js framework fails, but the language was downloaded anyway
    installed_languages = get_installed_language_packs(force=True)

    # here we want to reference the language meta data we've loaded into memory
    context = update_context(request)
    context.update({
        "installed_languages": installed_languages.values(),
    })
    return context
示例#6
0
def initialize_content_caches(force=False):
    """
    Catch all function to regenerate any content caches in memory that need annotation
    with file availability
    """
    for lang in i18n.get_installed_language_packs(force=True).keys():
        logging.info("Preloading exercise data for language {lang}.".format(lang=lang))
        topic_tools.get_exercise_cache(force=force, language=lang)
        logging.info("Preloading content data for language {lang}.".format(lang=lang))
        topic_tools.get_content_cache(force=force, annotate=True, language=lang)
        logging.info("Preloading topic tree data for language {lang}.".format(lang=lang))
        topic_tools.get_topic_tree(force=force, annotate=True, language=lang)
示例#7
0
def initialize_content_caches(force=False):
    """
    Catch all function to regenerate any content caches in memory that need annotation
    with file availability
    """
    for lang in i18n.get_installed_language_packs(force=True).keys():
        logging.info(
            "Preloading exercise data for language {lang}.".format(lang=lang))
        topic_tools.get_exercise_cache(force=force, language=lang)
        logging.info(
            "Preloading content data for language {lang}.".format(lang=lang))
        topic_tools.get_content_cache(force=force,
                                      annotate=True,
                                      language=lang)
        logging.info("Preloading topic tree data for language {lang}.".format(
            lang=lang))
        topic_tools.get_topic_tree(force=force, annotate=True, language=lang)
示例#8
0
 def is_language_installed(self, lang_code, force_reload=True):
     return lang_code in get_installed_language_packs(force=force_reload)
示例#9
0
 def is_language_installed(self, lang_code, force_reload=True):
     return lang_code in get_installed_language_packs(force=force_reload)
示例#10
0
    def __init__(self, facility, admin_access=False, *args, **kwargs):
        super(FacilityUserForm, self).__init__(*args, **kwargs)

        self.admin_access = admin_access
        self.fields["default_language"].choices = [(lang_code, get_language_name(lang_code)) for lang_code in get_installed_language_packs()]

        # Select the initial default language,
        #   but only if we're not in the process of updating it to something else.
        if not self.fields["default_language"].initial and "default_language" not in self.changed_data:
            self.fields["default_language"].initial = (self.instance and self.instance.default_language) or get_default_language()

        # Passwords only required on new, not on edit
        self.fields["password_first"].required = self.instance.pk == ""
        self.fields["password_recheck"].required = self.instance.pk == ""

        # Across POST and GET requests
        self.fields["zone_fallback"].initial = facility.get_zone()
        self.fields["facility"].initial = facility
        self.fields["facility"].queryset = Facility.objects.by_zone(facility.get_zone())
        self.fields["group"].queryset = FacilityGroup.objects.filter(facility=facility)