Ejemplo n.º 1
0
    def create_university(self):
        from ututi.model import LocationTag, EmailDomain

        # parse short title from url
        title_short = urlparse(self.university_site_url).netloc
        if title_short.startswith('www.'):
            title_short = title_short.replace('www.', '', 1)

        university = LocationTag(self.university_title, title_short, confirmed=False)

        # fill out the rest of information
        university.site_url = self.university_site_url
        university.logo = self.university_logo
        university.country = self.university_country
        university.member_policy = self.university_member_policy
        for domain_name in self.university_allowed_domains.split(','):
            university.email_domains.append(EmailDomain(domain_name))

        return university
Ejemplo n.º 2
0
    def create(self):
        values = self.form_result

        structure = LocationTag(title=values['title'],
                                title_short=values['title_short'],
                                description=values['description'],
                                member_policy='PUBLIC')
        structure.region_id = int(values['region']) or None

        if values.get('logo_upload', None) is not None:
            logo = values['logo_upload']
            structure.logo = logo.file.read()

        meta.Session.add(structure)

        # XXX why zero?
        if int(values['parent']) != 0:
            parent = meta.Session.query(LocationTag).filter_by(id=values['parent']).one()
            parent.children.append(structure)
        meta.Session.commit()
        redirect(url(controller='structure', action='index'))