Exemple #1
0
def create_user(fbid):
    user = User(fbid)
    if request.params.get('present' == 'true'):
        w = Whitelist(fbid=fbid, registered = False)
        Session.add(w)
    Session.add(user)
    user.add_me_to_friends()
    return user
    def playlist(self, id):
        if not request.params.has_key('comment') or not id:
            abort(400)

        comment = request.params['comment']

        user = Session.query(User).get(session['userid'])
        playlist = Session.query(Playlist).get(id)
        if playlist:
            spotlight = Spotlight(user=user, playlist=playlist, comment=comment)
            Session.add(spotlight)
            Session.commit()
            return str(spotlight.id)
        else:
            abort(404)
    def album(self, id):
        if not request.params.has_key('comment') or not id:
            abort(400)

        comment = request.params['comment']

        user = Session.query(User).get(session['userid'])
        album = Session.query(Album).get(id)
        if album:
            spotlight = Spotlight(user=user, album = album, comment=comment)
            Session.add(spotlight)
            Session.commit()
            return str(spotlight.id)
        else:
            abort(404)
    def edit(self, id):
        if not request.params.has_key('comment') or not id:
            abort(400)

        #id = request.params.get('spot_id')
        comment = request.params.get('comment')
        spotlight = Session.query(Spotlight).filter(Spotlight.id == id)[0]
        user = Session.query(User).get(session['userid'])
        if not spotlight or not spotlight in user.spotlights:
            abort(404)

        spotlight.comment = comment
        Session.add(spotlight)
        Session.commit()
        
        return "1"
Exemple #5
0
    def feedback(self):
        if not request.params.has_key('email') or\
                not request.params.get('feedback'):
            return '0';
        user_email = request.params['email']
        user_feedback = request.params['feedback']
        user_browser = request.params.get('browser')

        browser = screen = user = ''
        user = Session.query(User).get(session['userid'])

        if user_browser:
            bdata = cjson.decode(urllib.unquote(user_browser))
            for key, value in bdata['browser'].items():
                browser = browser + "%s = %s\n" % (key, value)

            for key, value in bdata['screen'].items():
                screen = screen + "%s = %s\n" % (key, value)
        message = feedback_template % \
                (user_feedback, browser, screen)

        if (self.email_regex.match(user_email) != None):
            if user.email != user_email:
                user.email = user_email
                Session.add(user)
                Session.commit()
        else:
            user_email = None

        subject = 'harmonize.fm feedback from %s' % user.name
        
        def sendmail():
            cc = user_email
            if config['use_gmail'] == 'yes' or not user_email:
                frm = config['feedback_email']
                pword = config['feedback_password']
            else:
                frm = user_email
                pword = None
            mail(config['smtp_server'], config['smtp_port'],
                frm, pword,
                '*****@*****.**', subject, message, cc=cc)

        if not 'paste.testing_variables' in request.environ:
            thread.start_new_thread(sendmail, ())
        return '1'
Exemple #6
0
        def set_now_playing():
            if not request.params.has_key('pid'):
                return 'false'

            song = Session.query(Song).get(request.params.get('pid'))
            user = Session.query(User).get(session['userid'])
            # we need to now add the database entries for this song being played.
            # this includes setting the now playing and updating the song statistic song and source
            if request.params.has_key('source'):
                src = int(request.params.get('source'))
                if src in SongStat.sources:
                    session['src'] = src

            user.nowplaying = song
            Session.add(user)
            Session.commit()
            user.update_profile()
            return 'true'
Exemple #7
0
    def setup_user():
        session['fbsession']= facebook.session_key
        session['fbuid']= facebook.uid
        if request.params.get('present') == 'true':
            session['present'] = True

        if not qualified_for_login(facebook.uid, 1) and not \
                request.params.get('present') == 'true':
            return False

        user = Session.query(User).filter(
            User.fbid==facebook.uid).first()        
        if not user:
            user = create_user(facebook.uid)

        user.lastseen = datetime.now()
        user.fbsession = facebook.session_key

        Session.add(user)
        Session.commit()
        session['userid'] = user.id
        session.save()
        return True
Exemple #8
0
 def set_volume(self, id):
     user = Session.query(User).get(session['userid'])
     user.lastvolume = id
     Session.add(user)
     Session.commit()
     return '1'