Changeset 890:01626215f2ac
- Timestamp:
- 08/28/10 13:53:37 (3 years ago)
- Branch:
- trunk
- Files:
-
- 1 added
- 8 edited
-
adhocracy/controllers/proposal.py (modified) (2 diffs)
-
adhocracy/lib/auth/authorization.py (modified) (1 diff)
-
adhocracy/lib/democracy/__init__.py (modified) (1 diff)
-
adhocracy/model/__init__.py (modified) (5 diffs)
-
adhocracy/model/poll.py (modified) (3 diffs)
-
adhocracy/model/user.py (modified) (2 diffs)
-
adhocracy/templates/proposal/tiles.html (modified) (1 diff)
-
development.ini (modified) (2 diffs)
-
scripts/create_indexes.sql (added)
Legend:
- Unmodified
- Added
- Removed
-
adhocracy/controllers/proposal.py
r864 r890 4 4 from pylons.i18n import _ 5 5 from formencode import foreach, Invalid 6 from sqlalchemy import or_, and_ 7 from sqlalchemy.orm import eagerload_all, eagerload 6 8 7 9 from adhocracy.lib.base import * … … 132 134 @RequireInstance 133 135 def show(self, id, format='html'): 134 c.proposal = get_entity_or_abort(model.Proposal, id) 135 require.proposal.show(c.proposal) 136 c.proposal = get_entity_or_abort(model.Proposal, id) 137 require.proposal.show(c.proposal) 138 139 #q = model.meta.Session.query(model.Proposal) 140 #id = int(unicode(id).split('-', 1)[0]) 141 #q = q.filter(model.Proposal.id==id) 142 #q = q.filter(model.Proposal.instance_id==c.instance.id) 143 #q = q.filter(or_(model.Proposal.delete_time==None, 144 # model.Proposal.delete_time>datetime.utcnow())) 145 #q = q.options(eagerload_all('parents')) 146 #q = q.options(eagerload_all('rate_poll.tallies')) 147 #q = q.options(eagerload_all('creator')) 148 #q = q.options(eagerload_all('rate_poll.tallies')) 149 #q = q.options(eagerload_all('taggings')) 150 #q = q.options(eagerload_all('description')) 151 #q = q.options(eagerload_all('description.creator')) 152 #q = q.options(eagerload_all('description.comments.revisions')) 153 #q = q.options(eagerload_all(model.Proposal._selections)) 154 #q = q.options(eagerload_all('_selections.page._texts')) 155 #q = q.options(eagerload_all('children')) 156 #q = q.options(eagerload_all('parents')) 157 #c.proposal = q.first() 136 158 137 159 if format == 'rss': -
adhocracy/lib/auth/authorization.py
r784 r890 59 59 even when they are not protected, thus making the authorization system more 60 60 configurable. 61 """ 61 """ 62 62 63 def evaluate(self, environ, credentials): 63 64 if c.user: 64 65 super(has_permission, self).evaluate(environ, credentials) 65 66 else: 66 anon_group = model.Group.by_code(model.Group.CODE_ANONYMOUS)67 for perm in anon_group.permissions:68 if perm.permission_name == self.permission_name:69 return70 self.unmet()67 if environ.get('anonymous_permissions') is None: 68 anon_group = model.Group.by_code(model.Group.CODE_ANONYMOUS) 69 environ['anonymous_permissions'] = [p.permission_name for p in anon_group.permissions] 70 if not self.permission_name in environ['anonymous_permissions']: 71 self.unmet() 71 72 72 73 -
adhocracy/lib/democracy/__init__.py
r788 r890 16 16 try: 17 17 for vote in model.Vote.all(): 18 handle_vote(vote) 18 pass 19 #handle_vote(vote) 19 20 except Exception, e: 20 21 log.exception("Cannot update tallies: %s" % e) -
adhocracy/model/__init__.py
r839 r890 75 75 mapper(Proposal, proposal_table, inherits=Delegateable, polymorphic_identity='proposal', properties={ 76 76 'description': relation(Page, primaryjoin=proposal_table.c.description_id==page_table.c.id, 77 uselist=False, backref=backref('_proposal')),77 uselist=False, lazy=True, backref=backref('_proposal')), 78 78 'rate_poll': relation(Poll, primaryjoin=proposal_table.c.rate_poll_id==poll_table.c.id, 79 uselist=False, lazy= True),79 uselist=False, lazy=False), 80 80 'adopt_poll': relation(Poll, primaryjoin=proposal_table.c.adopt_poll_id==poll_table.c.id, 81 81 uselist=False, lazy=True) … … 97 97 backref=backref('revisions', lazy=True, cascade='all')), 98 98 'comment': relation(Comment, lazy=False, backref=backref('revisions', cascade='all', 99 lazy= True, order_by=revision_table.c.create_time.desc())),99 lazy=False, order_by=revision_table.c.create_time.desc())), 100 100 'title': synonym('_title', map_column=True) 101 101 }, extension=meta.extension) … … 165 165 166 166 mapper(Tally, tally_table, properties={ 167 'poll': relation(Poll, backref=backref('tallies', lazy='dynamic')),167 'poll': relation(Poll, backref=backref('tallies', order_by=tally_table.c.create_time.desc(), lazy=True)), 168 168 'vote': relation(Vote, backref=backref('tally', uselist=False)) 169 169 }, extension=meta.extension) … … 190 190 'parent': relation(Text, lazy=True, uselist=False, 191 191 primaryjoin=text_table.c.parent_id==text_table.c.id), 192 'page': relation(Page, lazy=True, backref=backref('_texts', order_by=text_table.c.create_time.desc()),192 'page': relation(Page, lazy=True, backref=backref('_texts', lazy=False, order_by=text_table.c.create_time.desc()), 193 193 primaryjoin=text_table.c.page_id==page_table.c.id) 194 194 }, extension=meta.extension) … … 198 198 'proposal': relation(Proposal, lazy=True, backref=backref('_selections'), 199 199 primaryjoin=selection_table.c.proposal_id==proposal_table.c.id), 200 'page': relation(Page, lazy= False, backref=backref('_selections'),200 'page': relation(Page, lazy=True, backref=backref('_selections'), 201 201 primaryjoin=selection_table.c.page_id==page_table.c.id) 202 202 }, extension=meta.extension) -
adhocracy/model/poll.py
r778 r890 3 3 4 4 from sqlalchemy import Table, Column, Integer, Unicode, UnicodeText, ForeignKey, DateTime, func, or_ 5 from sqlalchemy.orm import reconstructor 5 from sqlalchemy.orm import reconstructor, aliased, eagerload, eagerload_all 6 6 7 7 import meta … … 93 93 def tally(self): 94 94 if self._tally is None: 95 from tally import Tally 96 q = self.tallies 97 q = q.order_by(Tally.create_time.desc()) 98 q = q.order_by(Tally.id.desc()) 99 _tally = q.limit(1).first() 100 if _tally is None: 101 _tally = Tally.create_from_poll(self) 102 self._tally = _tally 95 if len(self.tallies): 96 self._tally = self.tallies[0] 97 else: 98 from tally import Tally 99 self._tally = Tally.create_from_poll(self) 103 100 return self._tally 104 101 … … 198 195 q = meta.Session.query(Poll) 199 196 q = q.filter(Poll.subject.in_(subjects)) 197 q = q.options(eagerload(Poll.tallies)) 200 198 if not include_deleted: 201 199 q = q.filter(or_(Poll.end_time==None, -
adhocracy/model/user.py
r778 r890 5 5 6 6 from sqlalchemy import Table, Column, Integer, Unicode, UnicodeText, Boolean, DateTime, func, or_ 7 from sqlalchemy.orm import eagerload_all 7 8 8 9 from babel import Locale … … 270 271 User.delete_time>datetime.utcnow())) 271 272 if instance: 273 q = q.options(eagerload_all('memberships')) 272 274 q = q.join(Membership) 273 275 q = q.filter(or_(Membership.expire_time==None, -
adhocracy/templates/proposal/tiles.html
r887 r890 43 43 <li><a title="${_('Who is receiving delegations?')}" 44 44 href="${h.entity_url(proposal, member='delegations')}" 45 class="delegations ttip">${_("Delegations")} (${len(proposal.current_delegations())})</a></li> 45 class="delegations ttip">${_("Delegations")} 46 ##(${len(proposal.current_delegations())}) 47 </a></li> 46 48 %endif 47 49 <li><a title="${_('Who has helped?')}" 48 50 href="${h.entity_url(proposal, member='contributors')}" class="contributors ttip"> 49 ${_("Contributors")} (${len(proposal.contributors())})</a></li> 51 ${_("Contributors")} 52 ##(${len(proposal.contributors())}) 53 </a></li> 50 54 </ul> 51 55 <br/> -
development.ini
r433 r890 107 107 # Logging configuration 108 108 [loggers] 109 keys = root, routes,adhocracy, sqlalchemy109 keys = root, adhocracy, sqlalchemy 110 110 111 111 [handlers] … … 131 131 132 132 [logger_sqlalchemy] 133 #level = INFO 134 level = WARN 135 #level = DEBUG 136 handlers = 133 level = DEBUG 134 handlers = console 137 135 qualname = sqlalchemy.engine 138 # "level = INFO" logs SQL queries.139 # "level = DEBUG" logs SQL queries and results.140 # "level = WARN" logs neither. (Recommended for production systems.)141 136 142 137 [handler_console]
Note: See TracChangeset
for help on using the changeset viewer.
