def create_login_block(company, site): """ Given a ``Company`` and a ``SeoSite`, creates a login block for that company on that site. Inputs: :company: Who should own the login block :site: The SeoSite the login block should appear on Output: The resulting ``LoginBlock`` instance. """ page = Page.objects.create(name="%s Login Page" % company.name, page_type=Page.LOGIN) page.sites.add(site) row = Row.objects.create() row_order = RowOrder.objects.create(row=row, page=page, order=0) template = raw_base_template(LoginBlock) login_block = LoginBlock.objects.create(name="%s Login Block" % company.name, offset=0, span=12, template=template) BlockOrder.objects.create(block=login_block, row=row, order=0) return login_block
def create_login_block(company, site): """ Given a ``Company`` and a ``SeoSite`, creates a login block for that company on that site. Inputs: :company: Who should own the login block :site: The SeoSite the login block should appear on Output: The resulting ``LoginBlock`` instance. """ page = Page.objects.create( name="%s Login Page" % company.name, page_type=Page.LOGIN) page.sites.add(site) row = Row.objects.create() row_order = RowOrder.objects.create(row=row, page=page, order=0) template = raw_base_template(LoginBlock) login_block = LoginBlock.objects.create( name="%s Login Block" % company.name, offset=0, span=12, template=template) BlockOrder.objects.create(block=login_block, row=row, order=0) return login_block
def test_create_login_block(self): """ Ensures that a login block is createed with the correct associations and a valid template. """ company = CompanyFactory(name='Marketplace Company') site = SeoSite.objects.create(domain='somewhereelse.jobs') template = raw_base_template(LoginBlock) response = self.client.get("/login", follow=True) login_block = create_login_block(company, site) # validate that the correct template was assigned to the login block self.assertEqual(login_block.template, template)
def __init__(self, *args, **kwargs): super(BlockForm, self).__init__(*args, **kwargs) self.fields['template'].initial = models.raw_base_template(self.Meta.model) self.fields['head'].initial = models.raw_base_head(self.Meta.model)
def __init__(self, *args, **kwargs): super(BlockForm, self).__init__(*args, **kwargs) self.fields['template'].initial = models.raw_base_template( self.Meta.model) self.fields['head'].initial = models.raw_base_head(self.Meta.model) autofocus_input(self)