示例#1
0
    def create(self):
        if hasattr(self, 'form_result'):
            values = self.form_result

            year = int(values.get('year') or date.today().year)
            group = Group(group_id=values['id'],
                          title=values['title'],
                          description=values['description'],
                          year=date(year, 1, 1))

            group.mailinglist_enabled = True
            group.location = values.get('location', None)

            meta.Session.add(group)

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

            group.add_member(c.user, admin=True)
            meta.Session.commit()
            redirect(group.url(action='invite_members_step'))

        defaults = dict([('location-%d' % n, tag)
                         for n, tag in enumerate(c.user.location.hierarchy())])
        c.preset_location = c.user.location
        return htmlfill.render(self._create_form(), defaults=defaults)
示例#2
0
def test_setup(test):
    """Create some models needed for the tests."""
    ututi.tests.setUp(test)
    initialize_dictionaries(meta.engine)
    config = pylons.test.pylonsapp.config
    config['default_search_dict'] = 'public.universal'

    vu = LocationTag(u'Vilniaus universitetas', u'vu', u'', member_policy='PUBLIC')
    ef = LocationTag(u'Ekonomikos fakultetas', u'ef', u'', vu, member_policy='PUBLIC')

    meta.Session.add(vu)
    meta.Session.add(ef)

    # We need someone who can create subjects and groups
    user = User(u'User', '*****@*****.**', vu, 'password')
    meta.Session.add(user)
    meta.Session.commit()

    meta.Session.execute("SET default_text_search_config TO 'public.universal'")
    meta.set_active_user(user.id)

    l = LocationTag(u'Kauno technologijos universitetas', u'ktu', u'', member_policy='PUBLIC')
    f = LocationTag(u'Ekologijos fakultetas', u'ef', u'', l, member_policy='PUBLIC')

    mtag = SimpleTag(u'Ekologijos fakultetas') #a mixed tag

    meta.Session.add(l)
    meta.Session.add(f)

    g = Group('agroup', u'Ekologai', description=u'testas')
    g.location = f
    meta.Session.add(g)

    g = Group('new_group', u'Bioinformatikai', description=u'Grup\u0117 kurioje domimasi biologija ir informatika')
    meta.Session.add(g)

    # a tagged group
    g2 = Group('new_grp', u'Biology students', description=u'biologija matematika informatikos mokslas')
    g2.location = LocationTag.get(u'vu/ef')

    meta.Session.add(g2)
    tg = SimpleTag(u'test tag')
    g2.tags.append(tg)

    s = Subject(u'subj_id', u'Test subject', LocationTag.get(u'VU'))
    s.description = u'pagrindai'
    t = SimpleTag(u'a tag')
    meta.Session.add(t)
    s.tags.append(t)
    s.tags.append(mtag)
    meta.Session.add(s)
    p = Page(u'page title', u'Puslapio tekstas')
    meta.Session.add(p)
    s.pages.append(p)

    s = Subject('biologija', u'Biologijos pagrindai', LocationTag.get(u'vu'))
    p = Page(u'page title', u'Puslapio tekstas')
    s.pages.append(p)
    meta.Session.add(s)
    meta.Session.add(p)

    f = File(u'test.txt', u'geografija', 'text/txt')
    f.parent = s
    meta.Session.add(f)

    meta.Session.commit()
    meta.Session.execute("SET default_text_search_config TO 'public.universal'")