def test_unlink(self): template = list(Template.select())[0] publishable = Publishable() publishable.set("enabled", True, "en") publishable.template = template publishable.insert() datastore.commit() browser.open("/en/cms/content/%d/fields" % publishable.id) admin_login() assert not browser.is_element_present( "css=.template_field .control .new") assert not browser.is_element_present( "css=.template_field .control .delete") browser.click("css=.template_field .control .unlink") browser.wait_for_page_to_load(10000) val = browser.get_value("edited_item_template") assert not browser.get_value("edited_item_template")
def test_translation_enabled(self): from cocktail.translations import language_context from woost.models import (Publishable, ReadPermission, ReadTranslationPermission) self.everybody_role.permissions.append( ReadPermission(matching_items={ "type": "woost.models.publishable.Publishable" })) self.everybody_role.permissions.append(ReadTranslationPermission()) self.config.languages = ["en"] self.config.published_languages = [] with language_context("en"): a = Publishable() a.per_language_publication = True a.translation_enabled = True a.insert() b = Publishable() b.per_language_publication = True b.translation_enabled = False b.insert() c = Publishable() c.per_language_publication = True c.translation_enabled = True c.insert() d = Publishable() d.per_language_publication = True d.set("translation_enabled", True, "de") d.insert() e = Publishable() e.per_language_publication = False e.enabled = True e.insert() accessible = self.accessible_items() print a in accessible print b in accessible print c in accessible print d in accessible print e in accessible assert self.accessible_items() == set([a, c, e]) self.config.published_languages = ["en"] assert self.accessible_items() == set([a, c, e]) with language_context("de"): self.config.published_languages = ["de"] assert self.accessible_items() == set([d, e])