Beispiel #1
0
   def getPosts(self, request):
        print("Entered Get Posts Portion")
        temp = request.collegeId
        temp2 = request.clubId
        print "temp" + str(temp)
        print "temp2" + str(temp2)
        if(temp2==None):
            print "None"
            collegeId = ndb.Key('CollegeDb',int(temp))
            posts = Post.query(Post.collegeId==collegeId).order(-Post.timestamp)
        elif(temp==None):
            print "None"
            clubId = ndb.Key('Club',int(temp2))
            posts = Post.query(Post.club_id==clubId).order(-Post.timestamp)

        else:
            print "Not None"
            collegeId = ndb.Key('CollegeDb',int(temp))
            clubId = ndb.Key('Club',int(temp2))
            posts = Post.query(Post.collegeId==collegeId,Post.club_id==clubId).order(-Post.timestamp)

        #pylist =[copyPostToForm(x) for x in posts]
        #print "the list"
        #print pylist

        return Posts(items=list(reversed([copyPostToForm(x) for x in posts])))
    def GET(self, user):
        login = LoginModel.LoginModel()
        user_info = login.get_profile(user)

        post_model = Posts.Posts()
        posts = post_model.get_user_posts(user)
        return render.Profile(posts, user_info)
Beispiel #3
0
    def GET(self, user):
        login = LoginModel.LoginModel()
        user_info = login.get_profile(user)

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()
        return render.profile(render2.fecth_post(posts, user_info))
Beispiel #4
0
 def POST(self):
     print("DOING POST ACTIVITY")
     data = web.input()
     data.username = session_data['user']['username']
     post_model = Posts.Posts()
     post_model.insert_post(data)
     return "success"
Beispiel #5
0
def dropPost(id):
	user_id = request.args.get('user_id')
	if not user_id:
		return jsonify({'status':'failed','error':'missing fields'})
	if not uv.loginStatus(user_id):
                return jsonify({'status':'failed','error':'user not logged in'})
	return jsonify(pst.Posts().delete(id=id, user_id=user_id))
    def POST(self):
        data = web.input()
        data.username = session_data['user']['username']

        post_model = Posts.Posts()

        return post_model.insert_post(data)
Beispiel #7
0
    def GET(self):

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()

        # print("Hello, World!")
        # return
        # return render.MainLayout()
        return render.Home(posts)
Beispiel #8
0
 def POST(self):
     data = web.input()
     data.username = session_data["user"]["username"]
     post_model = Posts.Posts()
     added_comment = post_model.add_comment(data)
     if added_comment:
         return added_comment
     else:
         return {"error": "403"}
Beispiel #9
0
def editPost(id):
	user_id = request.args.get('user_id')
	title = request.args.get('title')
	body = request.args.get('body')
	if not user_id or not title or not body:
		return jsonify({'status':'failed','error':'missing fields'})
	if not uv.loginStatus(user_id):
                return jsonify({'status':'failed','error':'user not logged in'})
	return jsonify(pst.Posts().edit(id=id, user_id=user_id, title=title, body=body))
    def POST(self):
        data = web.input()

        # We need to store posts with every user's name to tell who posted what
        data.username = session_data['user']['username']

        # Here we will make a call to out model Posts.py inside that we will call Posts class
        post_model = Posts.Posts()
        post_model._insert_post(data)
        return 'success'
Beispiel #11
0
 def GET(self):
     post_model = Posts.Posts()
     posts = post_model.get_all_posts(None)
     if session_data['user']:
         login = LoginModel.LoginModel()
         user_info = login.get_profile(session_data['user']['username'])
         posts = post_model.get_all_posts(user_info['username'])
         return render.home(posts, user_info)
     else:
         return render.home(posts, None)
Beispiel #12
0
    def POST(self):
        data = web.input()
        data.username = session_data['user']['username']

        post_model = Posts.Posts()
        added_comment = post_model.add_comment(data)

        if added_comment:
            return added_comment
        else:
            return {'error': '403'}
Beispiel #13
0
    def POST(self):
        data = web.input()
        data.username = session_data['user']['username']

        delete_model = Posts.Posts()
        delete_post = delete_model.delete_post(data)

        if delete_post:
            return 'success'
        else:
            return 'Error'
Beispiel #14
0
    def GET(self):
        # data = type('obj', (object,), {"email" : "test", "password" : "test"})
        #
        # login = LoginModel.LoginModel()
        # isCorrect = login.check_login(data)
        #
        # if isCorrect:
        #     session_data['user'] = isCorrect

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()
        return render.Home(posts)
Beispiel #15
0
 def GET(self):
     #data = type('obj', (object,), {"username": "******", "password": "******"})
     #login = LoginModel.LoginModel()
     #is_correct = login.check_user(data)
     
     #if is_correct:
         #session_data["user"] = is_correct
     
     post_model = Posts.Posts()
     posts = post_model.get_all_posts()
     
     return render.Home(posts)
Beispiel #16
0
    def GET(self):
        data = type('obj', (object,), {"username": "******", "password" : "jaiambe1234"})
        print("Control passed to Home screen for :", data.username, " and" , data.password)
        login = LoginModel.LoginModel()

        isCorrect = login.check_user(data)
        print("Control passed to Home screen for 2 :", data.username, " and", data.password)

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()

        return render.Home(posts)
Beispiel #17
0
    def GET(self):
        # data = type('obj', (object,), {'username': '******', 'password': '******'})

        # login = LoginModel.LoginModel()
        # isCorrect = login.check_user(data)

        # if isCorrect:
        #     session_data['user'] = isCorrect

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()

        return render.Home(posts)
Beispiel #18
0
    def GET(self):
        data = type('obj', (object,), {"username" : "genius", "password" : "123"})
        login = LoginModel.LoginModel()

        isCorrect = login.check_user(data)

        if isCorrect:
            session_data["user"] = isCorrect

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()

        return render.Home(posts) # this will open the MainLayout.html with Home.html content
Beispiel #19
0
    def GET(self, user):
        login = LoginModel.LoginModel()
        post_model = Posts.Posts()
        if user is None:
            user_info = login.get_profile(None)
            posts = post_model.get_user_posts(None)
        else:
            user_info = login.get_profile(user)
            posts = post_model.get_user_posts(user)

        print(render)

        return render.Profile(posts, user_info)
    def GET(self):
        data = type('obj', (object,), {"username": "******", "password": "******"})

        login = LoginModel.LoginModel()
        isCorrect = login.check_user(data)

        if isCorrect:
            session_data['user'] = isCorrect

        post_model = Posts.Posts();
        posts = post_model.get_all_posts()

        return render.Home(posts)
Beispiel #21
0
    def GET(self):
        data = type('obj', (object, ), {
            'username': '******',
            'password': '******'
        })
        login = LoginModel.LoginModel()
        isValid = login.check_user(data)
        if isValid:
            session_data['user'] = isValid

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()

        return render.Home(posts)
    def GET(self, username):
        # data = type('obj', (object,), {"username": "******", "password": "******"})

        login = LoginModel.LoginModel()
        # isCorrect = login.check_user(data)

        # if isCorrect:
        #     session_data['user'] = isCorrect
        
        user_info = login.get_profile(username)
        
        post_model = Posts.Posts()
        posts = post_model.get_user_posts(username)
        return render.Profile(posts, user_info)
Beispiel #23
0
    def GET(self, user):
        data = type('obj', (object, ), {
            "username": "******",
            "passworde": "dengo"
        })

        login = LoginModel.LoginModel()
        isCorrect = login.check_user(data)

        if isCorrect:
            session_data["user"] = isCorrect

        post_model = Posts.Posts()
        posts = post_model.get_user_posts(user)
        return render.Profile(posts)
Beispiel #24
0
    def GET(self):
        data = type('obj', (object, ), {
            'username': '******',
            'password': '******'
        })

        login = LoginModel.LoginModel()
        is_correct = login.check_login(data)

        if is_correct:
            session_data["user"] = is_correct

        posts_model = Posts.Posts()
        posts = posts_model.get_all_posts()

        return render.Home(posts)
Beispiel #25
0
    def GET(self):
        data = type('obj', (object, ), {
            "username": "******",
            "password": "******"
        })

        login = LogiModel.LoginModel()
        isCorrect = login.check_user(data)

        if isCorrect:
            session_data["user"] = isCorrect

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()

        return render.Home(posts)
Beispiel #26
0
    def GET(self, user):
        data = type('obj', (object, ), {
            "username": "******",
            "password": "******"
        })

        login = LoginModel.loginModel()
        user_info = login.get_profile(user)
        isCorrect = login.check_user(data)

        if isCorrect:
            session_data["user"] = isCorrect

        post_model = Posts.Posts()
        posts = post_model.get_user_posts(user)
        return render.Profile(posts, user_info)
Beispiel #27
0
    def GET(self, user):
        data = type('obj', (object, ), {
            "username": "******",
            "password": "******"
        })

        login = LoginModel.LoginModel()
        isCorrect = login.check_user(data)

        if isCorrect:  # starts session
            session_data['user'] = isCorrect

        post_model = Posts.Posts()
        posts = post_model.get_user_posts(user)

        return render.Profile(posts)
Beispiel #28
0
    def GET(self):
        # forces a static user remove when finished
        data = type('obj', (object, ), {
            "username": "******",
            "password": "******"
        })

        login = LoginModel.LoginModel()
        isCorrect = login.check_user(data)

        if isCorrect:  # starts session
            session_data['user'] = isCorrect

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()

        return render.home(posts)
Beispiel #29
0
    def GET(self):
        # Autologin.
        data = type('obj', (object, ), {
            "username": "******",
            "password": "******"
        })

        login = LoginModel.LoginModel()

        isCorrect = login.check_user(data)
        if isCorrect:
            session_data["user"] = isCorrect

        post_model = Posts.Posts()
        all_posts = post_model.get_all_posts()

        return render.home(all_posts)
    def GET(self):

        post_model = Posts.Posts()
        posts = post_model.get_all_posts()

        return render.Home(posts)