def dashboard(request): userID = request.session.get('id', False) if userID: user = User.objects.get(id = userID) if user.profile.notification == '': return redirect('exchange-registration') bullets = PostManager.fetchBulletin(user) msgCount = PostManager.uncheckMessageCount(user) return render(request, 'dashboard.html', locals())
def search(request): userID = request.session.get('id', False) if userID: user = User.objects.get(id = userID) if user.profile.notification == '': return redirect('exchange-registration') else: msgCount = PostManager.uncheckMessageCount(user) if request.GET: urlHelper = UrlHelper() params = urlHelper.validate(request.GET, {'q'}, {'p'}) if params and params['q'] != '': page = 0 if params['p']: page = int(params['p']) query = params['q'] results = SearchManager.offerResults(query, user) return render(request, 'search.html', locals()) return redirect('exchange-home')
def index(request, page = 1): userID = request.session.get('id', False) user = None posts = [] paging = [] if userID: user = User.objects.get(id = userID) if user.profile.notification == '' or not user.parent_community: return redirect('exchange-registration') else: msgCount = PostManager.uncheckMessageCount(user) page = int(page) pageCount = PostManager.countPage(user.parent_community) prevPage = max(1, page - 1) nextPage = min(max(pageCount, 1), page + 1) posts = PostManager.fetch(page, user.parent_community) paging = PostManager.paging(page, user.parent_community) if posts == None: return redirect('exchange-home') return render(request, 'index.html', locals()) else: return render(request, 'landing.html', locals())