def get_more(request): if request.method == 'POST': try: filter = request.GET.__getitem__('cluster') except: filter = '-1' if 'upload' in request.POST['type']: return render( request, 'memes/posts.html', { 'memes': Utils.getForFind(request.POST['filter'], request.POST['offset']) }) elif 'fresh' in request.POST['type']: return render(request, 'memes/posts.html', {'memes': Utils.getFresh(request.POST['offset'])}) elif 'hot' in request.POST['type']: return render(request, 'memes/posts.html', {'memes': Utils.getHottest(request.POST['offset'])}) elif 'relevant' in request.POST['type']: return render( request, 'memes/posts.html', { 'memes': Utils.getFromClusterLabel(request.POST['filter'], request.POST['offset'], 10) }) return HttpResponse("404")
def upload(request): clusters_name = [] try: filter = request.GET.__getitem__('filter') clusters_name = filter.split(',') cluster_text = models.Cluster.objects.filter(name=clusters_name[0], type='text').last() if (len(clusters_name) > 1): cluster_label = models.Cluster.objects.filter( name=clusters_name[1], type='tag').last() else: cluster_label = models.Cluster.objects.all()[0:0] except Exception as ex: filter = '' cluster_text = models.Cluster.objects.all()[0:0] cluster_label = models.Cluster.objects.all()[0:0] try: pic_url = 'users_images/' + request.GET.__getitem__('source') except: pic_url = '' return render( request, 'memes/upload.html', { 'memes': Utils.getForFind(filter, 0), 'pic_url': pic_url, 'cluster_text': cluster_text, 'cluster_label': cluster_label, 'has_filter': len(clusters_name) > 0 })