def main(): parser = create_parser(description=__doc__) parser.add_argument( "-t", dest="template", default=template, type=unicode, help=("The template to use. " "(default: '%s', possible keys: %s)" % (template, possible_attrs)), ) args = parser.parse_args() load_from_args(args) instances = get_instances(args) query = User.all_q() if instances is not None: instance_ids = [instance.id for instance in instances] query = query.filter( User.memberships.any( and_( Membership.instance_id.in_(instance_ids), or_(Membership.expire_time == None, Membership.expire_time > datetime.utcnow()), ) ) ) for user in query: userinfo = user_info(user) s = args.template.format(**userinfo) print s.encode("utf-8")
def main(): parser = create_parser(description=__doc__) parser.add_argument("-t", dest="template", default=template, type=unicode, help=("The template to use. " "(default: '%s', possible keys: %s)" % (template, possible_attrs))) args = parser.parse_args() load_from_args(args) instances = get_instances(args) query = User.all_q() if instances is not None: instance_ids = [instance.id for instance in instances] query = query.filter( User.memberships.any( and_( Membership.instance_id.in_(instance_ids), or_(Membership.expire_time == None, Membership.expire_time > datetime.utcnow())))) for user in query: userinfo = user_info(user) s = args.template.format(**userinfo) print s.encode('utf-8')
def main(): parser = create_parser(description=__doc__) args = parser.parse_args() load_from_args(args) instances = get_instances(args) for instance in instances: proposals = Proposal.all_q(instance=instance) proposals = sorted(proposals, key=lambda x: x.comment_count(), reverse=True) print instance.label for proposal in proposals: print "%s: %s" % (proposal.comment_count(), proposal.title)
def main(): parser = create_parser(description=__doc__, use_instance=False) parser.add_argument( "username", help=("The name of the user who should become a global admin")) args = parser.parse_args() load_from_args(args) user = User.find(args.username) if user is None: print 'Cannot find user %s\n' % args.username parser.exit() global_membership = [membership for membership in user.memberships if membership.instance is None][0] admin_group = Group.by_code(Group.CODE_ADMIN) global_membership.group = admin_group meta.Session.commit()