def get(request): """ static method for get """ # redirect active session if SessionHandler.isUserSessionAlive(request.session): loginUser = SessionHandler.getSessionUser(request.session) if "keywords" in request.GET.keys(): keywords = request.GET["keywords"] # gets keywords from URL as string feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets feed list of the user filter = SearchFeed(feeds, keywords) # get feed information parsedFeeds = filter.getFilteredFeeds() count = len(parsedFeeds) feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets all feeds of a user return render_to_response( "search.html", { "parsedFeeds": parsedFeeds, "user": loginUser, "keywords": keywords, "count": count, "feeds": feeds, }, context_instance=RequestContext(request), ) return HttpResponseRedirect("/feedreader/")
def get(request): """ static method for get """ # redirect active session if SessionHandler.isUserSessionAlive(request.session): loginUser = SessionHandler.getSessionUser(request.session) feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets the feeds of the user frmLogin = LoginForm() parsedFeedEntries = [] for feed in feeds: #parsedFeeds.append(ParsedFeed(feed)) pf = ParsedFeed(feed) for entry in pf.entries: parsedFeedEntries.append(entry) tmp = sorted(parsedFeedEntries, cmp=IndexView.sortFeedEntries, reverse=True) parsedFeedEntriesSorted = [] for i in range(0,len(tmp)): parsedFeedEntriesSorted.append(tmp[i]) return render_to_response('index.html', {'login': frmLogin, 'user': loginUser, 'feeds': feeds, 'parsedFeedEntries': parsedFeedEntriesSorted}, context_instance=RequestContext(request)) else: # displays new login form frmLogin = LoginForm() return render_to_response('index.html', {'login': frmLogin, 'user': '******'}, context_instance=RequestContext(request))
def get(request): """ static method for get """ # redirect active session if SessionHandler.isUserSessionAlive(request.session): loginUser = SessionHandler.getSessionUser(request.session) if "fid" in request.GET.keys() and "eid" in request.GET.keys(): fid = request.GET["fid"] eid = request.GET["eid"] feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets the feeds of the user feed = DatabaseProvider.getFeedByUserIdAndFeedId(loginUser.id, fid) # gets a feed of the user pFeed = ParsedFeed(feed) entry = [] for e in pFeed.entries: if e.id == eid: entry.append(e) break return render_to_response( "displayfeedentry.html", {"feeds": feeds, "feed": pFeed, "entry": entry[0], "user": loginUser}, context_instance=RequestContext(request), ) return HttpResponseRedirect("/feedreader/")
def get(request): """ static method for get """ activeFeeds = '' activeUser = '' if 'pagetab' in request.GET.keys(): pageTab = request.GET['pagetab'] if(pageTab == 'user'): activeFeeds = '' activeUser = '******' else: activeFeeds = 'active' activeUser = '' # redirect active session if SessionHandler.isUserSessionAlive(request.session): loginUser = SessionHandler.getSessionUser(request.session) formAddFeed = AddFeedForm() formManageUser = UserManageForm() feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets the feeds of the user return render_to_response('manage.html', {'frmAddFeed': formAddFeed, 'user': loginUser, 'feeds': feeds, 'manage': formManageUser, 'mail': loginUser.email, 'activeFeeds': activeFeeds, 'activeUser': activeUser}, context_instance=RequestContext(request)) return HttpResponseRedirect('/feedreader/')
def post(request): """ static method for post """ if 'submitNewFeed' in request.POST: form = AddFeedForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'].encode('ascii', 'ignore') url = form.cleaned_data['url'].encode('ascii', 'ignore') validate = URLValidator() try: validate(url) except ValidationError, e: loginUser = SessionHandler.getSessionUser(request.session) formAddFeed = AddFeedForm() formManageUser = UserManageForm() error = "The feed URL you provided seems to be incorrect!" feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets the feeds of the user return render_to_response('manage.html', {'frmAddFeed': formAddFeed, 'user': loginUser, 'feeds': feeds, 'manage': formManageUser, 'mail': loginUser.email, 'errorurl': error}, context_instance=RequestContext(request)) loginUser = SessionHandler.getSessionUser(request.session) DatabaseProvider.addNewFeed(loginUser.id, name, url) # adds new newfeed for user formAddFeed = AddFeedForm() formManageUser = UserManageForm() success = "Feed successfully added!" feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets the feeds of the user return render_to_response('manage.html', {'frmAddFeed': formAddFeed, 'user': loginUser, 'feeds': feeds, 'manage': formManageUser, 'mail': loginUser.email, 'success': success}, context_instance=RequestContext(request)) # invalid form else: loginUser = SessionHandler.getSessionUser(request.session) formAddFeed = AddFeedForm() formManageUser = UserManageForm() error = "Form is invalid" feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets the feeds of the user return render_to_response('manage.html', {'frmAddFeed': formAddFeed, 'user': loginUser, 'feeds': feeds, 'manage': formManageUser, 'mail': loginUser.email, 'errorurl': error}, context_instance=RequestContext(request))
def get(request): """ static method for get """ # redirect active session if SessionHandler.isUserSessionAlive(request.session): loginUser = SessionHandler.getSessionUser(request.session) if 'info' in request.GET.keys() and 'fid' in request.GET.keys(): if request.GET['info'] == 'show': feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets the feeds of the user feed = DatabaseProvider.getFeedByUserIdAndFeedId(loginUser.id, request.GET['fid']) # gets the feed with the id of the user pFeed = ParsedFeed(feed) return render_to_response('displayfeedinfo.html', {'feedinfo': pFeed, 'feeds': feeds, 'user': loginUser}, context_instance=RequestContext(request)) return HttpResponseRedirect('/feedreader/')
def get(request): """ static method for get """ # redirect active session if SessionHandler.isUserSessionAlive(request.session): loginUser = SessionHandler.getSessionUser(request.session) if 'fid' in request.GET.keys(): feedId = request.GET['fid'] feed = DatabaseProvider.getFeedByUserIdAndFeedId(loginUser.id, feedId) # gets the specific feed of the user parsedFeed = ParsedFeed(feed) feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets all feeds of a user return render_to_response('displayfeed.html', {'feed': parsedFeed, 'feeds': feeds, 'user': loginUser}, context_instance=RequestContext(request)) return HttpResponseRedirect('/feedreader/')
elif 'submitChangePw' in request.POST: form = UserManageForm(request.POST) if form.is_valid(): password = form.cleaned_data['password'].encode('ascii', 'ignore') user = request.session['active_User'] # get user id from session user.set_password(password) user.save() loginUser = SessionHandler.getSessionUser(request.session) formAddFeed = AddFeedForm() formManageUser = UserManageForm() success = "Password successfully changed!" feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets the feeds of the user return render_to_response('manage.html', {'frmAddFeed': formAddFeed, 'user': loginUser, 'feeds': feeds, 'manage': formManageUser, 'mail': loginUser.email, 'success': success}, context_instance=RequestContext(request)) # invalid form else: loginUser = SessionHandler.getSessionUser(request.session) formAddFeed = AddFeedForm() formManageUser = UserManageForm() error = "Invalid password (Min. 8 Characters)!" feeds = DatabaseProvider.getFeedsByUserId(loginUser.id) # gets the feeds of the user return render_to_response('manage.html', {'frmAddFeed': formAddFeed, 'user': loginUser, 'feeds': feeds, 'manage': formManageUser, 'mail': loginUser.email, 'errorpw': error}, context_instance=RequestContext(request))