def show_ventures(request, venture_id=None): if venture_id == 'search': if request.method != 'POST': return redirect(request, '/business/ventures/') search = request.POST['search'] if not search: return redirect(request, '/business/ventures/') template = 'business/show_ventures.html' ventures = Venture.objects.filter(name__icontains=search).order_by( 'name') elif venture_id: venture = Venture.objects.get(pk=venture_id) subventures = Venture.objects.filter(parent=venture).order_by('name') template = 'business/show_venture.html' else: ventures = Venture.objects.filter(parent=None).order_by('name') template = 'business/show_ventures.html' side_ventures = Venture.objects.filter(parent=None).order_by('name') synergy_url_base = SYNERGY_URL_BASE return render(request, template, locals())
def update_score(request, content_type, object_id, value, voter=None): if not voter: voter_model = Vote.voter.field.rel.to if voter_model is User: voter = request.user else: voter = request.user.get_profile() if voter_model is not voter.__class__: raise ImproperlyConfigured("voter not passed to the" "`update_score()` view. Write a `process_view()` " "middleware to pass it. This is not required if the voter " "model is `User` or `user_instance.get_profile()`.") ct = get_object_or_404(ContentType, pk=int(content_type)) obj = get_object_or_404(ct.model_class(), pk=int(object_id)) score = TotalScore.update(obj, voter, int(value), ct=ct) return redirect(request, reverse('lckd-score:show', args=[int(content_type), int(object_id)]))
def update_score(request, content_type, object_id, value, voter=None): if not voter: voter_model = Vote.voter.field.rel.to if voter_model is User: voter = request.user else: voter = request.user.get_profile() if voter_model is not voter.__class__: raise ImproperlyConfigured( "voter not passed to the" "`update_score()` view. Write a `process_view()` " "middleware to pass it. This is not required if the voter " "model is `User` or `user_instance.get_profile()`.") ct = get_object_or_404(ContentType, pk=int(content_type)) obj = get_object_or_404(ct.model_class(), pk=int(object_id)) score = TotalScore.update(obj, voter, int(value), ct=ct) return redirect( request, reverse('lckd-score:show', args=[int(content_type), int(object_id)]))