Пример #1
0
 def invite(self):
     if request.POST:
         who = request.params['who']
         c.code = ''.join(random.choice(string.letters + string.digits) for i in xrange(32))
         invite = Invite(who, c.code)
         Session.begin()
         Session.add(invite)
         Session.commit()
         return render('/display-invite.html')
     else:
         return render('/create-invite.html')
Пример #2
0
 def index(self):
     c.cname = "music"
     c.cdesc = "a collection of requests to manipulate, broadcast, and augment the 'music' database"
     c.methods = [{'n':'addtracks','d':'add tracks living in the music directory.'},
                  {'n':'addmeta','d':'for all tracks that have been added, add in metadata from musicbrainz.'}
                  ]
     return render('describe_controller.mako')
Пример #3
0
 def index(self):
     # Return a rendered template
     #return render('/init.mako')
     # or, return a response
     #qc.autoset('sb_address')
     c.sb_address=qc.query('sb_address')
     c.sb_port=qc.query('sb_port')
     return render('init_index.mako')
Пример #4
0
 def index(self):
     c.cname = "queries"
     c.cdesc = "a collection of prepacked queries that will return json"
     c.methods = [{'n':'getFriends','d':'add tracks living in the music directory.'},
                  {'n':'getLocalMusic','d':'A list of tracks on this computer.'},
                  {'n':'getFriendsMusic','d':'A list of tracks on friends computers.'}
                  ]
     return render('describe_controller.mako')
Пример #5
0
 def pp2(self):
     artists = Session.query(Artist)
     tracks = Session.query(Track)
     paths = []
     for r in tracks:
         paths.append( os.path.join('.media', r.filepath ))
         
     return render('/hello2.html')
Пример #6
0
 def index(self):
     # Return a rendered template
     #return render('/friends.mako')
     # or, return a response
     c.cname = "friends"
     c.cdesc = "a collection of requests to manipulate, broadcast, and augment the 'friends' database"
     c.methods = [{'n':'addknown','d':'adds a seed friend at swiftway'},
                  {'n':'list','d':'list current friends'},
                  {'n':'friendallknown','d':'add currently known server to friends'},
                  {'n':'annoucetoall','d':'::stub::'},
                  {'n':'hearabout','d':'called by a remote serve to announce itself'}
                  ]
     return render('describe_controller.mako')
Пример #7
0
    def index(self):
        # Return a rendered template
        # return render('/plug.mako')
        # or, return a responsels t

        w = sh.wrap("config")
        d = w.queryToDict(
            "select plugin.name  as name, user.name as uname from plugin, user where user.id = plugin.user;"
        )

        print d

        c.pluglist = map(lambda x: str(x["name"]), d)
        c.plugnames = map(lambda x: str(x["uname"]), d)
        c.cname = "plug"
        c.cdesc = "Plugin html interface"
        c.methods = [{"n": "blank", "d": "none yet"}]
        jsfiles = ["jquery"]
        rendered0 = sh.sourced_js(jsfiles, True)
        rendered = rendered0 + render("/plug_list.mako")
        rendered = rendered + render("/describe_controller.mako")

        return rendered
Пример #8
0
 def index(self):
     c.playsEver, c.ipsEver = Session.query(func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).one()
     c.plays7d, c.ips7d = Session.query(func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(days=7)).one()
     c.plays24h, c.ips24h = Session.query(func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(days=1)).one()
     c.plays1h, c.ips1h = Session.query(func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(hours=1)).one()
     statsEver = Session.query(User.user_name, func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).outerjoin(TrackPlay).group_by(User.user_name).all()
     stats7d = Session.query(User.user_name, func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).outerjoin(TrackPlay).group_by(User.user_name).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(days=7)).all()
     stats24h = Session.query(User.user_name, func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).outerjoin(TrackPlay).group_by(User.user_name).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(days=1)).all()
     stats1h = Session.query(User.user_name, func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).outerjoin(TrackPlay).group_by(User.user_name).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(hours=1)).all()
     stats = {}
     for uname, count, ipcount in statsEver:
         stats[uname] = {'user':uname, 'countEver':count, 'ipEver':ipcount, 'count7d':0, 'ip7d':0, 'count24h':0, 'ip24h':0, 'count1h':0, 'ip1h':0}
     for uname, count, ipcount in stats7d:
         stats[uname].update({'count7d':count, 'ip7d':ipcount})
     for uname, count, ipcount in stats24h:
         stats[uname].update({'count24h':count, 'ip24h':ipcount})
     for uname, count, ipcount in stats1h:
         stats[uname].update({'count1h':count, 'ip1h':ipcount})
     statlist = stats.values()
     statlist.sort(key=itemgetter('countEver'), reverse=True)
     c.stats = statlist
     return render('/stats.html')
Пример #9
0
 def register(self, code):
     invite = Session.query(Invite).filter_by(code=code).first()
     if invite is None:
         return 'Your registration code appears to be invalid.'
     c.code = code
     return render('/register.html')
Пример #10
0
 def login(self):
     return render('login.html')
Пример #11
0
 def index(self):
     c.username = request.environ['repoze.what.credentials']['repoze.what.userid']
     c.admin = 'admins' in request.environ['repoze.what.credentials']['groups']
     return render('/hello.html')
Пример #12
0
 def i2g(self):
     return render('/h2grav.html')
Пример #13
0
 def i2(self):
     return render('/h2player.html')
Пример #14
0
 def index(self):
     return render('/hello2.html')
Пример #15
0
 def index(self):
     c.all_controllers=['/music',
                        '/friends',
                        '/init']
     return render('main_index.mako')
Пример #16
0
 def index(self):
     return render('/rosa_template.html')
Пример #17
0
 def all(self):
     c.urls=['/music/addtracks',
             '/music/addmeta',
             '/friends/addknown',
             '/friends/friendallknown']
     return render('init_all.mako')
Пример #18
0
 def serveMako(self, name):
     c.username = sh.unameFromCookie(request.cookies["authkit"])
     return render(name + ".mako")
Пример #19
0
 def demo(self):
     return render('/isdemo.html')