rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
buff=self.find_buffer(user,thread) if buff: return buff
conv=self.find_conversation(user,thread) if conv: return conv
def find_or_make(self,user,thread): bset=self.settings["buffer"] if bset=="separate": pass elif bset=="per-thread": buff=self.find_buffer(user,thread) if buff: return buff elif bset=="per-user": buff=self.find_buffer(user,None) if buff: return buff thread=None else: buff=self.find_buffer(None,None) if buff: return buff...
buff=self.find_buffer(user,None) if buff: return buff
conv=self.find_conversation(user,None) if conv: return conv
def find_or_make(self,user,thread): bset=self.settings["buffer"] if bset=="separate": pass elif bset=="per-thread": buff=self.find_buffer(user,thread) if buff: return buff elif bset=="per-user": buff=self.find_buffer(user,None) if buff: return buff thread=None else: buff=self.find_buffer(None,None) if buff: return buff...
buff=self.find_buffer(None,None) if buff: return buff
conv=self.find_conversation(None,None) if conv: return conv
def find_or_make(self,user,thread): bset=self.settings["buffer"] if bset=="separate": pass elif bset=="per-thread": buff=self.find_buffer(user,thread) if buff: return buff elif bset=="per-user": buff=self.find_buffer(user,None) if buff: return buff thread=None else: buff=self.find_buffer(None,None) if buff: return buff...
buff=Conversation(self,user,thread)
conv=Conversation(self,user,thread)
def find_or_make(self,user,thread): bset=self.settings["buffer"] if bset=="separate": pass elif bset=="per-thread": buff=self.find_buffer(user,thread) if buff: return buff elif bset=="per-user": buff=self.find_buffer(user,None) if buff: return buff thread=None else: buff=self.find_buffer(None,None) if buff: return buff...
if not self.buffers.has_key(key): self.buffers[key]=[buff] else: self.buffers[key].append(buff)
if not self.conversations.has_key(key): self.conversations[key]=[conv] else: self.conversations[key].append(conv)
def find_or_make(self,user,thread): bset=self.settings["buffer"] if bset=="separate": pass elif bset=="per-thread": buff=self.find_buffer(user,thread) if buff: return buff elif bset=="per-user": buff=self.find_buffer(user,None) if buff: return buff thread=None else: buff=self.find_buffer(None,None) if buff: return buff...
cjc_globals.screen.display_buffer(buff.buffer) return buff
cjc_globals.screen.display_buffer(conv.buffer) return conv
def find_or_make(self,user,thread): bset=self.settings["buffer"] if bset=="separate": pass elif bset=="per-thread": buff=self.find_buffer(user,thread) if buff: return buff elif bset=="per-user": buff=self.find_buffer(user,None) if buff: return buff thread=None else: buff=self.find_buffer(None,None) if buff: return buff...
buff=self.find_buffer(fr,thread)
conv=self.find_conversation(fr,thread)
def message_error(self,stanza): if self.settings["buffer"]=="separate": return 0 fr=stanza.get_from() thread=stanza.get_thread()
if not buff and bset in ("per-thread","per-user","single"): buff=self.find_buffer(fr,thread) if not buff and bset in ("per-user","single"): buff=self.find_buffer(fr,None) if not buff and bset=="single": buff=self.find_buffer(None,None) if not buff:
if not conv and bset in ("per-thread","per-user","single"): conv=self.find_conversation(fr,thread) if not conv and bset in ("per-user","single"): conv=self.find_conversation(fr,None) if not conv and bset=="single": conv=self.find_conversation(None,None) if not conv:
def message_error(self,stanza): if self.settings["buffer"]=="separate": return 0 fr=stanza.get_from() thread=stanza.get_thread()
buff.error(stanza)
conv.error(stanza)
def message_error(self,stanza): if self.settings["buffer"]=="separate": return 0 fr=stanza.get_from() thread=stanza.get_thread()
buff=self.find_or_make(fr,thread) self.cjc.send_event("message received",body) buff.add_received(fr,subject,body,thread,timestamp)
def message_normal(self,stanza): fr=stanza.get_from() thread=stanza.get_thread() subject=stanza.get_subject() body=stanza.get_body() if not subject and not body: return if body is None: body=u"" d=delay.get_delay(stanza) if d: timestamp=d.get_datetime_local() else: timestamp=None
self.last_record = records[0][0]
def fill_top_underflow(self, lines_needed): if not self.archive: return if self.last_record: older_than = self.last_record else: older_than = self.conversation.start_time record_iter = self.archive.get_records('message', self.conversation.peer, older_than = older_than, limit = lines_needed, order = Archive.REVERSE_CHRO...
if self.plugin.buffers.has_key(key): l=self.plugin.buffers[key]
if self.plugin.conversations.has_key(key): l=self.plugin.conversations[key]
def cmd_close(self,args): args.finish() if self.peer: key=self.peer.bare().as_unicode() else: key=None if self.plugin.buffers.has_key(key): l=self.plugin.buffers[key] if self in l: l.remove(self) self.buffer.close() return 1
for buffers in self.conversations.values(): for conv in buffers:
for conversations in self.conversations.values(): for conv in conversations:
def ev_day_changed(self,event,arg): for buffers in self.conversations.values(): for conv in buffers: conv.buffer.append_themed("message.day_change",{},activity_level=0) conv.buffer.update()
" {1}, {2} ({3} bits)".format(unicode(self.stream.peer), ssl_version, cipher, ssl_version, bits))
" {1}, {2} ({3} bits)".format(unicode(self.stream.peer), ssl_version, cipher, bits))
def tls_connected(self, tls): cipher, ssl_version, bits = tls.cipher() self.__logger.info("Encrypted connection to {0} established using" " {1}, {2} ({3} bits)".format(unicode(self.stream.peer), ssl_version, cipher, ssl_version, bits)) verified = self.settings.get("tls_verify", True) if verified and not self.cert_verif...
self.pos = self.offset_back(self.window.iw, self.window.ih - 1, self.pos)
self.pos = self.offset_back(self.window.iw, self.window.ih - 1, pos)
def page_up(self): """Handle page-up request.""" with self.lock: logger.debug("page_up, self.pos = {0!r}".format(self.pos)) self.pos = self.offset_back(self.window.iw, self.window.ih - 1, self.pos) logger.debug(" after offset back: self.pos = {0!r}" .format(self.pos)) if self.pos == (0, 0): formatted = self._format(se...
if c>255 or c<0: cjc_globals.screen.beep() return c=chr(c)
def _keypressed(self,c,escape): if c>255 or c<0: cjc_globals.screen.beep() return c=chr(c) if self.is_printable(c): self.key_char(c) else: cjc_globals.screen.beep()
c=unicode(c,cjc_globals.screen.encoding,"replace")
def key_char(self,c): c=unicode(c,cjc_globals.screen.encoding,"replace") if not self.string_choice and c in self.single_choice: return self.answer(c) if self.pos>=self.w-len(self.prompt)-2: return cjc_globals.screen.beep() newcontent=self.content+c if c in string.digits and self.range_choice: pass elif newcontent in se...
auto_away=self.settings["auto_away"] auto_xa=self.settings["auto_xa"]
auto_away = self.settings.get("auto_away") auto_xa = self.settings.get("auto_xa")
def ev_idle(self,event,arg): if not self.cjc.stream: return auto_away=self.settings["auto_away"] auto_xa=self.settings["auto_xa"] if auto_away and auto_xa: minidle=min(auto_away,auto_xa) elif auto_away: minidle=auto_away elif auto_xa: minidle=auto_xa else: return idle=int(arg/60) if idle<minidle: return p=self.cjc.get_...
fparams["jid"] = self.conversation.peer
fparams["jid"] = record.peer
def fill_top_underflow(self, lines_needed): if not self.archive: return record_iter = self.archive.get_records('chat', self.conversation.peer, older_than = self.last_record, limit = lines_needed, order = Archive.REVERSE_CHRONOLOGICAL) records = list(record_iter) if not records: return records.reverse() self.last_record...
fparams["jid"] = self.conversation.me
fparams["jid"] = record.peer
def fill_top_underflow(self, lines_needed): if not self.archive: return record_iter = self.archive.get_records('chat', self.conversation.peer, older_than = self.last_record, limit = lines_needed, order = Archive.REVERSE_CHRONOLOGICAL) records = list(record_iter) if not records: return records.reverse() self.last_record...
if not self.cjc.stream:
if not self.cjc.stream and args.get():
def cmd_chat(self,args): peer=args.shift() if not peer: self.error("/chat without arguments") return
self.last_record = conversation.start_time
self.last_record = None
def __init__(self, conversation): self.conversation = conversation try: self.archive = cjc_globals.application.plugins.get_service(Archive) except KeyError: self.archive = None ui.TextBuffer.__init__(self, conversation.fparams, "chat.descr", "chat buffer", conversation) self.last_record = conversation.start_time
older_than = self.last_record, limit = lines_needed,
older_than = older_than, limit = lines_needed,
def fill_top_underflow(self, lines_needed): if not self.archive: return record_iter = self.archive.get_records('chat', self.conversation.peer, older_than = self.last_record, limit = lines_needed, order = Archive.REVERSE_CHRONOLOGICAL) records = list(record_iter) if not records: return records.reverse() self.last_record...
def __init__(self,plugin,me,peer,thread=None): self.start_time = datetime.now()
def __init__(self,plugin,me,peer,thread=None, start_time = None): self.start_time = start_time if start_time else datetime.now()
def __init__(self,plugin,me,peer,thread=None): self.start_time = datetime.now() self.plugin=plugin self.me=me self.peer=peer if thread: self.thread=thread self.thread_inuse=1 else: plugin.last_thread+=1 self.thread="chat-thread-%i" % (plugin.last_thread,) self.thread_inuse=0 self.fparams={ "peer":self.peer, "jid":self....
m=pyxmpp.Message(to_jid=self.peer,stanza_type="chat",body=s,thread=self.thread) self.plugin.cjc.stream.send(m) self.add_sent(s)
def user_input(self,s): if not self.plugin.cjc.stream: self.buffer.append_themed("error","Not connected") self.buffer.update() return 0
archivers = self.cjc.plugins.get_services(Archiver) for archiver in archivers: archiver.log_event("chat", fr, 'in', timestamp, subject, body, thread)
def message_chat(self,stanza): fr=stanza.get_from() thread=stanza.get_thread() subject=stanza.get_subject() body=stanza.get_body() if body is None: body=u"" if subject: body=u"%s: %s" % (subject,body) elif not body: return
conv=Conversation(self,self.cjc.jid,fr,thread)
conv=Conversation(self,self.cjc.jid,fr,thread, timestamp)
def message_chat(self,stanza): fr=stanza.get_from() thread=stanza.get_thread() subject=stanza.get_subject() body=stanza.get_body() if body is None: body=u"" if subject: body=u"%s: %s" % (subject,body) elif not body: return
return list(set(map(lambda v: v.delegation, self.relevant_votes)))
return filter(lambda d: d is not None, list(set(map(lambda v: v.delegation, self.relevant_votes))))
def _delegations(self): """ The set of delegations which have determined this decision, as per ``relevant_votes``. :returns: list of ``Delegation`` """ return list(set(map(lambda v: v.delegation, self.relevant_votes)))
instance = model.Instance(tt_make_str(), "foo schnasel", tt_make_user()) model.meta.Session.add(instance)
instance = model.Instance.find(u"test") if not instance: instance = model.Instance(u"test", u"foo schnasel", tt_make_user()) model.meta.Session.add(instance) model.meta.Session.flush()
def tt_get_instance(): instance = model.Instance(tt_make_str(), "foo schnasel", tt_make_user()) model.meta.Session.add(instance) model.filter.setup_thread(instance) model.meta.Session.flush() return instance
model.meta.Session.flush()
def tt_get_instance(): instance = model.Instance(tt_make_str(), "foo schnasel", tt_make_user()) model.meta.Session.add(instance) model.filter.setup_thread(instance) model.meta.Session.flush() return instance
if not c.user:
if not c.user and not model.OpenID.by_id(openid):
def init(self): self.consumer = create_consumer(self.openid_session) openid = self.form_result.get("openid") try: authrequest = self.consumer.begin(openid) except DiscoveryFailure, e: return self._failure(openid, str(e)) if not c.user: axreq = ax.FetchRequest(h.instance_url(c.instance, path='/openid/update')) axreq.ad...
return int((len([ch for ch in text if ch == "\n"]) + len(text)/60) * 1.1)
return int((len([ch for ch in text if ch == "\n"]) + len(text)/70))
def field_rows(text): if text is None: return 10 return int((len([ch for ch in text if ch == "\n"]) + len(text)/60) * 1.1)
print 'inbound', delegations
def inbound(self, recurse=True, at_time=None, should_filter=True): """ Retrieve all inbound delegations (i.e. those that the user has received from other users in order to vote on their behalf) that apply to the ``Delegateable``. :param recurse: if ``True``, search will include delegations on parent ``Delegateables`` ...
result = ""
results = []
def autocomplete(self): try: prefix = unicode(request.params['q']) limit = int(request.params.get('limit', 15)) users = model.User.complete(prefix, limit) result = "" for user in users: s = user.name if user.user_name != user.name: s = "%s (%s)" % (user.user_name, s) result += "{s: '%s', k: '%s'}" % (s, user.user_name)...
result += "{s: '%s', k: '%s'}" % (s, user.user_name) return result
results.append("{display: '%s', user: '%s'}" % (s, user.user_name)) response.content_type = "text/javascript" return "[" + ",".join(results) + "]"
def autocomplete(self): try: prefix = unicode(request.params['q']) limit = int(request.params.get('limit', 15)) users = model.User.complete(prefix, limit) result = "" for user in users: s = user.name if user.user_name != user.name: s = "%s (%s)" % (user.user_name, s) result += "{s: '%s', k: '%s'}" % (s, user.user_name)...
if c.instance:
if c.instance and not self.__instance_group:
def _instance_group(self): if c.instance: m = self.user.instance_membership(c.instance) return m.group if m else None return None
return m.group if m else None return None
self.__instance_group = m.group if m else None return self.__instance_group
def _instance_group(self): if c.instance: m = self.user.instance_membership(c.instance) return m.group if m else None return None
page = model.Page.find_fuzzy(match.group(1))
page = model.Page.find_fuzzy(match.group(1), include_deleted=True)
def page_sub(match): from adhocracy.lib import helpers as h page = model.Page.find_fuzzy(match.group(1)) if page is not None: return h.page_link(page) else: from adhocracy.forms import FORBIDDEN_NAMES return h.page_link(match.group(1), create=True)
if not len(title) or (title.lower() in FORBIDDEN_NAMES):
if (not len(title)) or (title.lower() in FORBIDDEN_NAMES):
def title2alias(title, pseudo=u'pg'): #title = urllib.unquote(title) title = escape(title) #title = INVALID_CHARS.sub(u"", title) if not len(title) or (title.lower() in FORBIDDEN_NAMES): return pseudo try: tint = int(title) return pseudo + tint except: return title
return u"<Poll(%d,%s,%s,%s)>" % (self.id,
return u"<Poll(%s,%s,%s,%s)>" % (self.id,
def __repr__(self): return u"<Poll(%d,%s,%s,%s)>" % (self.id, self.motion_id, self.begin_time, self.end_time)
Poll.motion = relation(motion.Motion, backref=backref('polls', cascade='delete',
Poll.motion = relation(motion.Motion, backref=backref('polls', cascade='all',
def find(cls, id, instance_filter=True): try: q = meta.Session.query(Poll) q = q.filter(Poll.id==int(id)) poll = q.one() if ifilter.has_instance() and instance_filter: poll = poll.motion.instance == ifilter.get_instance() \ and poll or None return poll except Exception: return None
return _hash(repr(obj).encode('utf-8'))
try: return _hash(repr(obj)) except: return _hash(unicode(obj))
def make_tag(obj): """ Collisisons here don't matter much. """ return _hash(repr(obj).encode('utf-8'))
if not value or len(value.strip()) < 2:
var = variant_normalize(value) if not var or len(var) < 2:
def _to_python(self, value, state): from adhocracy.lib.text import variant_normalize if not value or len(value.strip()) < 2: raise formencode.Invalid(_("No variant name is given."), value, state) var = variant_normalize(value) if var.lower() in FORBIDDEN_NAMES or not VALIDVARIANT.match(var.lower()): raise formencode.In...
var = variant_normalize(value)
def _to_python(self, value, state): from adhocracy.lib.text import variant_normalize if not value or len(value.strip()) < 2: raise formencode.Invalid(_("No variant name is given."), value, state) var = variant_normalize(value) if var.lower() in FORBIDDEN_NAMES or not VALIDVARIANT.match(var.lower()): raise formencode.In...
c.filter_made = self.form_result.get('filter_made')
if hasattr(self, 'form_result'): c.filter_made = self.form_result.get('filter_made') else: c.filter_made = 0
def index(self): scored = democracy.State.critical_proposals(c.instance) urgency_sort = sorting.dict_value_sorter(scored) proposals = scored.keys() c.filter_made = self.form_result.get('filter_made') if c.user and c.filter_made == 1: proposals = filter(lambda m: not democracy.Decision(c.user, m.poll).is_decided(), pro...
url = "<a href='%s' class='user_link'><img width='16' height='16' class='user_icon' src='%s' alt="" /> %s</a>" % (
url = u"<a href='%s' class='user_link'><img width='16' height='16' class='user_icon' src='%s' alt="" /> %s</a>" % (
def _generic_link(user, size, scope): url = "<a href='%s' class='user_link'><img width='16' height='16' class='user_icon' src='%s' alt="" /> %s</a>" % ( entity_url(user), gravatar_url(user, size=size), cgi.escape(user.name)) if scope: votes = user.number_of_votes_in_scope(scope) if votes > 0: url += "<sup>%s</sup>" % v...
url += "<sup>%s</sup>" % votes
url += u"<sup>%s</sup>" % votes
def _generic_link(user, size, scope): url = "<a href='%s' class='user_link'><img width='16' height='16' class='user_icon' src='%s' alt="" /> %s</a>" % ( entity_url(user), gravatar_url(user, size=size), cgi.escape(user.name)) if scope: votes = user.number_of_votes_in_scope(scope) if votes > 0: url += "<sup>%s</sup>" % v...
icon = "<img class='user_icon' width='16' height='16' src='/img/icons/delegate_16.png' />" url += "<a href='%s'>%s</a>" % (entity_url(delegation), icon)
icon = u"<img class='user_icon' width='16' height='16' src='/img/icons/delegate_16.png' />" url += u"<a href='%s'>%s</a>" % (entity_url(delegation), icon)
def _specific_link(user, size, scope, other): url = _generic_link(user, size, scope) if other and scope: dnode = democracy.DelegationNode(other, scope) for delegation in dnode.outbound(): if delegation.agent == user: icon = "<img class='user_icon' width='16' height='16' src='/img/icons/delegate_16.png' />" url += "<a h...
return instance_url(None, path='') + "/img/icons/proposal_adopted_" + str(size) + ".png"
return instance_url(None, path='') + u"/img/icons/proposal_adopted_" + str(size) + u".png"
def proposal_icon(proposal, size=16): if proposal.adopted: return instance_url(None, path='') + "/img/icons/proposal_adopted_" + str(size) + ".png" if proposal.is_adopt_polling(): return instance_url(None, path='') + "/img/icons/vote_" + str(size) + ".png" else: return instance_url(None, path='') + "/img/icons/proposal...
return instance_url(None, path='') + "/img/icons/vote_" + str(size) + ".png"
return instance_url(None, path='') + u"/img/icons/vote_" + str(size) + u".png"
def proposal_icon(proposal, size=16): if proposal.adopted: return instance_url(None, path='') + "/img/icons/proposal_adopted_" + str(size) + ".png" if proposal.is_adopt_polling(): return instance_url(None, path='') + "/img/icons/vote_" + str(size) + ".png" else: return instance_url(None, path='') + "/img/icons/proposal...
return instance_url(None, path='') + "/img/icons/proposal_" + str(size) + ".png"
return instance_url(None, path='') + u"/img/icons/proposal_" + str(size) + u".png"
def proposal_icon(proposal, size=16): if proposal.adopted: return instance_url(None, path='') + "/img/icons/proposal_adopted_" + str(size) + ".png" if proposal.is_adopt_polling(): return instance_url(None, path='') + "/img/icons/vote_" + str(size) + ".png" else: return instance_url(None, path='') + "/img/icons/proposal...
text = "<span class='tag_link %s'><a" % ("plain" if plain else "")
text = u"<span class='tag_link %s'><a" % ("plain" if plain else "")
def tag_link(tag, count=None, size=None, base_size=12, plain=False): text = "<span class='tag_link %s'><a" % ("plain" if plain else "") if size is not None: size = int(math.sqrt(size) * base_size) text += " style='font-size: %dpx !important;'" % size text += " href='%s' rel='tag'>%s</a>" % (entity_url(tag), cgi.escape(...
text += " style='font-size: %dpx !important;'" % size text += " href='%s' rel='tag'>%s</a>" % (entity_url(tag), cgi.escape(tag.name))
text += u" style='font-size: %dpx !important;'" % size text += u" href='%s' rel='tag'>%s</a>" % (entity_url(tag), cgi.escape(tag.name))
def tag_link(tag, count=None, size=None, base_size=12, plain=False): text = "<span class='tag_link %s'><a" % ("plain" if plain else "") if size is not None: size = int(math.sqrt(size) * base_size) text += " style='font-size: %dpx !important;'" % size text += " href='%s' rel='tag'>%s</a>" % (entity_url(tag), cgi.escape(...
text += "&thinsp;&times;" + str(count) text += "</span>"
text += u"&thinsp;&times;" + str(count) text += u"</span>"
def tag_link(tag, count=None, size=None, base_size=12, plain=False): text = "<span class='tag_link %s'><a" % ("plain" if plain else "") if size is not None: size = int(math.sqrt(size) * base_size) text += " style='font-size: %dpx !important;'" % size text += " href='%s' rel='tag'>%s</a>" % (entity_url(tag), cgi.escape(...
path = "/img/icons/page%s_%s.png"
path = u"/img/icons/page%s_%s.png"
def text_icon(text, page=None, size=16): if page is None: page = page path = "/img/icons/page%s_%s.png" if page.function == page.NORM: if text.variant != text.HEAD: return path % ("_variant", size) return path % ("_norm", size) elif page.function == page.DESCRIPTION: return proposal_icon(page.proposal, size=size) else:...
url = "/page/new?title=%s" % url
url = u"/page/new?title=%s" % url
def page_link(page, variant=model.Text.HEAD, create=False, link=True, icon=True, icon_size=16): if create: page = page.encode('utf-8').replace("&lt;", "<") page = page.replace("&gt;", ">") page = page.replace("&amp;", "&") url = urllib.quote(page) url = "/page/new?title=%s" % url url = instance_url(c.instance, path=url...
return "<a class='page_link new' href='%s'>%s</a>" % (url, page)
return u"<a class='page_link new' href='%s'>%s</a>" % (url, page)
def page_link(page, variant=model.Text.HEAD, create=False, link=True, icon=True, icon_size=16): if create: page = page.encode('utf-8').replace("&lt;", "<") page = page.replace("&gt;", ">") page = page.replace("&amp;", "&") url = urllib.quote(page) url = "/page/new?title=%s" % url url = instance_url(c.instance, path=url...
text = ""
text = u""
def page_link(page, variant=model.Text.HEAD, create=False, link=True, icon=True, icon_size=16): if create: page = page.encode('utf-8').replace("&lt;", "<") page = page.replace("&gt;", ">") page = page.replace("&amp;", "&") url = urllib.quote(page) url = "/page/new?title=%s" % url url = instance_url(c.instance, path=url...
text += "<img class='dgb_icon' src='%s' /> " % text_icon(_text, page, size=icon_size) text += "<a class='page_link exists' href='%s'>%s</a>"
text += u"<img class='dgb_icon' src='%s' /> " % text_icon(_text, page, size=icon_size) text += u"<a class='page_link exists' href='%s'>%s</a>"
def page_link(page, variant=model.Text.HEAD, create=False, link=True, icon=True, icon_size=16): if create: page = page.encode('utf-8').replace("&lt;", "<") page = page.replace("&gt;", ">") page = page.replace("&amp;", "&") url = urllib.quote(page) url = "/page/new?title=%s" % url url = instance_url(c.instance, path=url...
title = "%s <code>(%s)</code>" % (title, variant)
title = u"%s <code>(%s)</code>" % (title, variant)
def page_link(page, variant=model.Text.HEAD, create=False, link=True, icon=True, icon_size=16): if create: page = page.encode('utf-8').replace("&lt;", "<") page = page.replace("&gt;", ">") page = page.replace("&amp;", "&") url = urllib.quote(page) url = "/page/new?title=%s" % url url = instance_url(c.instance, path=url...
text = ""
text = u""
def proposal_link(proposal, icon=True, icon_size=16, link=True): text = "" if icon: text += "<img class='dgb_icon' src='%s' /> " % proposal_icon(proposal, size=icon_size) text += cgi.escape(proposal.title) if link and not proposal.is_deleted(): text = "<a href='%s' class='dgb_link'>%s</a>" % (entity_url(proposal), text...
text += "<img class='dgb_icon' src='%s' /> " % proposal_icon(proposal, size=icon_size)
text += u"<img class='dgb_icon' src='%s' /> " % proposal_icon(proposal, size=icon_size)
def proposal_link(proposal, icon=True, icon_size=16, link=True): text = "" if icon: text += "<img class='dgb_icon' src='%s' /> " % proposal_icon(proposal, size=icon_size) text += cgi.escape(proposal.title) if link and not proposal.is_deleted(): text = "<a href='%s' class='dgb_link'>%s</a>" % (entity_url(proposal), text...
text = "<a href='%s' class='dgb_link'>%s</a>" % (entity_url(proposal), text)
text = u"<a href='%s' class='dgb_link'>%s</a>" % (entity_url(proposal), text)
def proposal_link(proposal, icon=True, icon_size=16, link=True): text = "" if icon: text += "<img class='dgb_icon' src='%s' /> " % proposal_icon(proposal, size=icon_size) text += cgi.escape(proposal.title) if link and not proposal.is_deleted(): text = "<a href='%s' class='dgb_link'>%s</a>" % (entity_url(proposal), text...
return "<a target='_new' href='%s' onClick='return showHelp(\"%s\")'>%s</a>" % (full_url, simple_url, text)
return u"<a target='_new' href='%s' onClick='return showHelp(\"%s\")'>%s</a>" % (full_url, simple_url, text)
def help_link(text, page, anchor=None): url = instance_url(None, path="/static/%s.%s") if anchor is not None: url += "#" + anchor full_url = url % (page, 'html') simple_url = url % (page, 'simple') return "<a target='_new' href='%s' onClick='return showHelp(\"%s\")'>%s</a>" % (full_url, simple_url, text)
c.query = self.form_result.get("serp_q")
c.query = self.form_result.get("serp_q", u"*")
def query(self): require.proposal.index() c.query = self.form_result.get("serp_q") self._query_pager() return formencode.htmlfill.render(render("search/results.html"), {'q': c.query, 'serp_q': c.query})
c.query = self.form_result.get("serp_q", '') + '*'
c.query = self.form_result.get("serp_q", '') + u'*'
def filter(self): require.proposal.index() c.query = self.form_result.get("serp_q", '') + '*' self._query_pager() return c.entities_pager.here()
self.size = count_val.to_python(request.params.get("%s_size" % self.name)) except:
self.size = size_val.to_python(request.params.get("%s_size" % self.name)) except:
def _parse_request(self): try: page_val = validators.Int(min=1, not_empty=True) self.page = page_val.to_python(request.params.get("%s_page" % self.name)) except: self.page = 1 try: size_val = validators.Int(min=1, max=250, not_empty=True) self.size = count_val.to_python(request.params.get("%s_size" % self.name)) excep...
_("activity"): sorting.instance_activity,
def instances(instances): return NamedPager('instances', instances, tiles.instance.row, sorts={_("oldest"): sorting.entity_oldest, _("newest"): sorting.entity_newest, _("activity"): sorting.instance_activity, _("name"): sorting.delegateable_label}, default_sort=sorting.instance_activity)
default_sort=sorting.instance_activity)
default_sort=sorting.delegateable_label)
def instances(instances): return NamedPager('instances', instances, tiles.instance.row, sorts={_("oldest"): sorting.entity_oldest, _("newest"): sorting.entity_newest, _("activity"): sorting.instance_activity, _("name"): sorting.delegateable_label}, default_sort=sorting.instance_activity)
_("activity"): sorting.proposal_activity,
def proposals(proposals, detail=True): sorts = {_("oldest"): sorting.entity_oldest, #_("newest"): sorting.entity_newest, _("activity"): sorting.proposal_activity, _("newest comment"): sorting.delegateable_latest_comment, _("support"): sorting.proposal_support, _("name"): sorting.delegateable_label} return NamedPager('p...
for vote in votes: event.emit(event.T_VOTE_CAST, vote.user, instance=c.instance, topics=[c.poll.scope], vote=vote, poll=c.poll)
if c.poll.action != model.Poll.SELECT: for vote in votes: event.emit(event.T_VOTE_CAST, vote.user, instance=c.instance, topics=[c.poll.scope], vote=vote, poll=c.poll)
def vote(self, id, format='html'): c.poll = self._get_open_poll(id) if c.poll.action not in [model.Poll.ADOPT, model.Poll.SELECT]: abort(400, _("This is a rating poll, not an adoption poll.")) require.poll.vote(c.poll) decision = democracy.Decision(c.user, c.poll) votes = decision.make(self.form_result.get("position"))...
if scope and (not c.instance or c.instance.allow_delegation):
if scope and ((not c.instance) or c.instance.allow_delegate):
def _generic_link(user, size, scope): url = u"<a href='%s' class='user_link'><img width='16' height='16' class='user_icon' src='%s' alt="" /> %s</a>" % ( entity_url(user), gravatar_url(user, size=size), cgi.escape(user.name)) if scope and (not c.instance or c.instance.allow_delegation): votes = user.number_of_votes_in_...
def title2alias(title, pseudo=u'pg'):
def title2alias(title, pseudo=u'page_'):
def title2alias(title, pseudo=u'pg'): #title = urllib.unquote(title) title = escape(title) #title = INVALID_CHARS.sub(u"", title) if (not len(title)) or (title.lower() in FORBIDDEN_NAMES): return pseudo try: tint = int(title) return pseudo + tint except: return title
delegations = c.proposal.current_delegations()
def delegations(self, id, format="html"): c.proposal = get_entity_or_abort(model.Proposal, id) delegations = c.proposal.current_delegations() if format == 'json': return render_json(list(delegations)) c.tile = tiles.proposal.ProposalTile(c.proposal) c.delegations_pager = pager.delegations(delegations) self._common_me...
h.instance_url(c.instance, path="/proposal/%s" % str(c.proposal.id)),
h.instance_url(c.instance, path="/proposal/%s" % c.proposal.id),
def activity(self, id, format='html'): c.proposal = get_entity_or_abort(model.Proposal, id) events = model.Event.find_by_topic(c.proposal) if format == 'rss': return event.rss_feed(events, _("Proposal: %s") % c.proposal.label, h.instance_url(c.instance, path="/proposal/%s" % str(c.proposal.id)), description=_("Activit...
require.page.show(c.left.page)
require.page.show(c.right.page)
def _differ(self, left, right, options=None): if left == right: h.flash(_("Cannot compare identical text revisions.")) redirect(h.entity_url(right)) c.left, c.right = (left, right) c.left_options = options require.page.show(c.left.page) if c.left.page != c.right.page: require.page.show(c.right.page) right_html = right....
require.page.show(c.right.page)
h.flash(_("Cannot compare versions of different texts.")) redirect(h.entity_url(c.right))
def _differ(self, left, right, options=None): if left == right: h.flash(_("Cannot compare identical text revisions.")) redirect(h.entity_url(right)) c.left, c.right = (left, right) c.left_options = options require.page.show(c.left.page) if c.left.page != c.right.page: require.page.show(c.right.page) right_html = right....
try: return _hash(repr(obj)) except: return _hash(unicode(obj))
return _hash(repr(obj).encode('ascii', 'ignore'))
def make_tag(obj): """ Collisisons here don't matter much. """ try: return _hash(repr(obj)) except: return _hash(unicode(obj))
self.find_page()
self.lookup()
def __init__(self, name): self.exists = False self.title = _("Missing page: %s") % name self.body = "" self.name = name if self.VALID_PAGE.match(name): self.find_page()
def find_page(self):
def lookup(self): for locale in [c.locale, i18n.get_default_locale()] + i18n.LOCALES: loaded = self._lookup_lang(locale.language) if loaded is not None: break def _lookup_lang(self, lang):
def find_page(self): fmt = self.name + '.%s' + self.SUFFIX path = util.get_site_path(self.DIR, fmt % c.locale.language) if os.path.exists(path): return self._load(path) path = util.get_site_path(self.DIR, fmt % i18n.get_default_locale().language) if os.path.exists(path): return self._load(path) path = util.get_path(s...
path = util.get_site_path(self.DIR, fmt % c.locale.language) if os.path.exists(path): return self._load(path) path = util.get_site_path(self.DIR, fmt % i18n.get_default_locale().language) if os.path.exists(path): return self._load(path) path = util.get_path(self.DIR, fmt % c.locale.language)
path = util.get_path(self.DIR, fmt % lang)
def find_page(self): fmt = self.name + '.%s' + self.SUFFIX path = util.get_site_path(self.DIR, fmt % c.locale.language) if os.path.exists(path): return self._load(path) path = util.get_site_path(self.DIR, fmt % i18n.get_default_locale().language) if os.path.exists(path): return self._load(path) path = util.get_path(s...
path = util.get_path(self.DIR, fmt % i18n.get_default_locale().language) if path is not None and os.path.exists(path): return self._load(path)
return None
def find_page(self): fmt = self.name + '.%s' + self.SUFFIX path = util.get_site_path(self.DIR, fmt % c.locale.language) if os.path.exists(path): return self._load(path) path = util.get_site_path(self.DIR, fmt % i18n.get_default_locale().language) if os.path.exists(path): return self._load(path) path = util.get_path(s...
entities = [w.entity for w in watches if not isinstance(unicode, w.entity)]
entities = [w.entity for w in watches if not isinstance(w.entity, unicode)]
def watchlist(self, id, format='html'): require.watch.index() c.page_user = get_entity_or_abort(model.User, id, instance_filter=False) require.user.show(c.page_user) watches = model.Watch.all_by_user(c.page_user) entities = [w.entity for w in watches if not isinstance(unicode, w.entity)] c.entities_pager = NamedPager('...
(Vote.NO, Vote.NO): Vote.NO}.get((old, new))
(Vote.NO, Vote.NO): Vote.NO}.get((old, new), new)
def rate(self, id, format='html'): # rating is like polling but steps via absten, i.e. if you have # first voted "for", rating will first go to "abstain" and only # then produce "against"- c.poll = self._get_open_poll(id) if c.poll.action != model.Poll.RATE: abort(400, _("This is not a rating poll.")) decision = democ...
if (not co.topic.is_mutable())
if not co.is_mutable()
def edit(co): if (not co.topic.is_mutable()) return False if has('instance.admin'): return True if not (has('comment.edit') and show(co)): return False if (not co.wiki) and (not is_own(co)): return False return True
if (not co.wiki) and (not is_own(co)):
if not (co.wiki or is_own(co)):
def edit(co): if (not co.topic.is_mutable()) return False if has('instance.admin'): return True if not (has('comment.edit') and show(co)): return False if (not co.wiki) and (not is_own(co)): return False return True
if not co.is_mutable()
if not co.is_mutable():
def edit(co): if not co.is_mutable() return False if has('instance.admin'): return True if not (has('comment.edit') and show(co)): return False if not (co.wiki or is_own(co)): return False return True
return self.event.link_path(self)
try: return self.event.link_path(self) except: import adhocracy.lib.url as url if self.instance: return url.entity_url(self.instance) return url.instance_url(None)
def link(self): return self.event.link_path(self)
except: try: return crc32(repr(obj)) except: return crc32(unicode(obj))
except: pass try: return str(crc32(repr(obj))) except: pass return str(crc32(unicode(obj)))
def make_tag(obj): """ Collisisons here don't matter much. """ try: return str(hash(obj)) except: try: return crc32(repr(obj)) except: return crc32(unicode(obj))
sig = iden[:200] sig += "".join([make_tag(a) for a in args]) sig += "".join([make_tag(v) for k, v in kwargs.items()])
sig = unicode(iden[:200]) sig += u"".join([make_tag(a) for a in args]) sig += u"".join([make_tag(v) for k, v in kwargs.items()])
def make_key(iden, args, kwargs=None): sig = iden[:200] sig += "".join([make_tag(a) for a in args]) sig += "".join([make_tag(v) for k, v in kwargs.items()]) return sha1(sig).hexdigest()
if (not co.topic.is_mutable()) and co.textual:
if (not co.topic.is_mutable())
def edit(co): if (not co.topic.is_mutable()) and co.textual: return False if has('instance.admin'): return True if not (has('comment.edit') and show(co)): return False if not co.textual and ((not co.wiki) and (not is_own(co))): return False return True
if not co.textual and ((not co.wiki) and (not is_own(co))):
if (not co.wiki) and (not is_own(co)):
def edit(co): if (not co.topic.is_mutable()) and co.textual: return False if has('instance.admin'): return True if not (has('comment.edit') and show(co)): return False if not co.textual and ((not co.wiki) and (not is_own(co))): return False return True
log.debug(type(user_data))
log.debug(user_data)
def callback(self): request_token = session.get('request_token') if not request_token: h.flash(_("You have been logged out while authenticating " "at twitter. Please try again.")) redirect_to("/user/edit/%s" % str(c.user.user_name)) request_token = oauth.OAuthToken.from_string(request_token) req_api = create_oauth(key...
api.CreateFriendship(system_user())
api._FetchUrl("http://twitter.com/friendships/create.json", post_data={'screen_name': system_user()}, no_cache=True)
def callback(self): request_token = session.get('request_token') if not request_token: h.flash(_("You have been logged out while authenticating " "at twitter. Please try again.")) redirect_to("/user/edit/%s" % str(c.user.user_name)) request_token = oauth.OAuthToken.from_string(request_token) req_api = create_oauth(key...
+ "can send you notifications as direct messages")) except Exception, e: import traceback log.warn(e)
+ "can send you notifications as direct messages") % system_user()) except HTTPError, he: log.warn(he.read())
def callback(self): request_token = session.get('request_token') if not request_token: h.flash(_("You have been logged out while authenticating " "at twitter. Please try again.")) redirect_to("/user/edit/%s" % str(c.user.user_name)) request_token = oauth.OAuthToken.from_string(request_token) req_api = create_oauth(key...
query[k.encode('ascii', 'ignore')] = v.encode('utf-8')
query[unicode(k).encode('ascii', 'ignore')] = unicode(v).encode('utf-8')
def _common_url_builder(instance, base, id, query=None, **kwargs): url = instance_url(instance, path=u'/' + base + u'/' + unicode(id)) url = _append_member_and_format(url, **kwargs) if query is not None: for k, v in query.items(): query[k.encode('ascii', 'ignore')] = v.encode('utf-8') url = url + u'?' + unicode(urllib....
c.text_rows = text.field_rows(c.proposal.description.head)
c.text_rows = text.text_rows(c.proposal.description)
def edit(self, id, errors={}): c.proposal = get_entity_or_abort(model.Proposal, id) require.proposal.edit(c.proposal) c.text_rows = text.field_rows(c.proposal.description.head) return htmlfill.render(render("/proposal/edit.html"), defaults=dict(request.params), errors=errors, force_defaults=False)
entities = [w.entity for w in watches if not instance(unicode, w.entity)]
entities = [w.entity for w in watches if not isinstance(unicode, w.entity)]
def watchlist(self, id, format='html'): require.watch.index() c.page_user = get_entity_or_abort(model.User, id, instance_filter=False) require.user.show(c.page_user) watches = model.Watch.all_by_user(c.page_user) entities = [w.entity for w in watches if not instance(unicode, w.entity)] c.entities_pager = NamedPager('wa...
try: return str(hash(obj)) except: return crc32(repr(obj))
try: return str(hash(obj)) except: try: return crc32(repr(obj)) except: return crc32(unicode(obj))
def make_tag(obj): """ Collisisons here don't matter much. """ try: return str(hash(obj)) except: return crc32(repr(obj))
sig = iden[:200] + repr(args) + repr(kwargs)
sig = iden[:200] sig += "".join([make_tag(a) for a in args]) sig += "".join([make_tag(v) for k, v in kwargs.items()])
def make_key(iden, args, kwargs=None): sig = iden[:200] + repr(args) + repr(kwargs) return sha1(sig).hexdigest()