Skip to content

Commit

Permalink
Exclude current user when form isn't filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-hamilton committed Jun 7, 2020
1 parent 44984f7 commit 880f833
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions one_hit_wonder/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ def matches(request):
if request.method == 'POST':
subform = StateSubform(request.POST)
instance = subform.save(commit=False)

if hasattr(instance, 'state'):
state = instance.state
SearchAdForm
ads = Advertisement.objects.exclude(creator__user=request.user).filter(position_filled=False, location__state=state)
form = SearchAdForm(request.POST)
instance = form.save(commit=False)
Expand All @@ -136,7 +136,7 @@ def matches(request):
ads = Advertisement.objects.exclude(creator__user=request.user).filter(position_filled=False, location__state=state,
instrument__name=instrument.name)
if not hasattr(instance, 'state') and not hasattr(instance, 'instrument'):
ads = Advertisement.objects.filter(position_filled=False).order_by('location__state', 'instrument__name')
ads = Advertisement.objects.exclude(creator__user=request.user).filter(position_filled=False).order_by('location__state', 'instrument__name')
else:
ads = Advertisement.objects.exclude(creator__user=request.user).filter(position_filled=False).order_by('location__state', 'instrument__name')
return render(request, 'account/matches.html',
Expand Down

0 comments on commit 880f833

Please sign in to comment.