Esempio n. 1
0
 def _d(self, proj_id, confirmed = False):
     if (confirmed == True):
         proj = DBSession.query(Project).get(proj_id)
         label = proj.label
         proj.delete()
         DBSession.flush()
         flash(u'Deleted Project: "$s"' % label, 'warning')
     redirect(url('/project/list'))
Esempio n. 2
0
 def _c(self, confirmed = False, **kw):
     if confirmed:
         project = Project()
         try:
             DBSession.add(project)
             DBSession.flush()
         except:
             flash(u'Could not add Project: "%s"' % (project.label), 'error')
         flash(u'Added Project: "%s"' % (project.label))
         redirect(url('/project/' + project.id))
     redirect(url('/project/'))
Esempio n. 3
0
 def get_by_label(self, label):
     try:
         page = DBSession.query(Page).filter_by(label = unicode(label)).one()
     except NoResultFound:
         flash(u'Page "%s" not found' % (label))
         redirect(url('/page/new/' + label))
     render = bodyMarkup
     return dict(page = page, render = render)
Esempio n. 4
0
 def setUp(self):
     """Prepare model test fixture."""
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
Esempio n. 5
0
 def _r(self, page_id):
     page = DBSession.query(Page).get(page_id)
     render = bodyMarkup
     return dict(page = page, render = render)
Esempio n. 6
0
 def search(self, **kw):
     pages = DBSession.query(Page).filter_by(kw)
     return dict(pages = pages)
Esempio n. 7
0
 def list_by_updated(self):
     pages = DBSession.query(Page)
     #pages = DBSession.query(Page).order_by(Page.updated)
     return dict(pages = pages)
Esempio n. 8
0
 def list_by_label(self):
     pages = DBSession.query(Page).order_by(Page.label)
     return dict(pages = pages)
Esempio n. 9
0
 def _my_update_params(self, d, nullable=False):
     resources = DBSession.query(Resource).all()
     options = [(resource.id, "%s (%s)" % (resource.label, resource.rtype)) for resource in resources]
     d["options"] = options
     return d
Esempio n. 10
0
 def by_email_address(cls, email):
     """Return the user object whose email address is ``email``."""
     return DBSession.query(cls).filter_by(email_address=email).first()
Esempio n. 11
0
 def get(self, label):
     img = DBSession.query(Image).filter_by(label = unicode(label)).one()
     response.content_type = 'image/' + img.encoding
     #response.headerlist.append(('Content-Disposition', 'attachment;filename=' + image.image.filename))
     return img.data
Esempio n. 12
0
 def _r(self, proj_id):
     project = DBSession.query(Project).get(proj_id)
     return dict(project = project)
Esempio n. 13
0
 def search(self, **kw):
     projects = DBSession.query(Project).filter_by(kw)
     return dict(projects = projects)
Esempio n. 14
0
 def list_by_id(self):
     projects = DBSession.query(Project).order_by(Project.id)
     return dict(projects = projects)
Esempio n. 15
0
 def tearDown(self):
     """Finish model test fixture."""
     DBSession.rollback()
Esempio n. 16
0
 def test_query_obj(self):
     """Model objects can be queried"""
     obj = DBSession.query(self.klass).one()
     for key, value in self.attrs.iteritems():
         assert_equals(getattr(obj, key), value)
Esempio n. 17
0
 def by_user_name(cls, username):
     """Return the user object whose user name is ``username``."""
     return DBSession.query(cls).filter_by(user_name=username).first()
Esempio n. 18
0
 def _my_update_params(self, d, nullable=False):
     collections = DBSession.query(Collection).all()
     options = [(collection.id, "%s (%s)" % (collection.label, collection.rtype)) for collection in collections]
     d["options"] = options
     return d
Esempio n. 19
0
 def _u(self, proj_id, confirmed = False, **kw):
     if (confirmed == True):
         project = DBSession.query(Project).get(proj_id)
         DBSession.flush()
     redirect(url('/project/' + project.id))