fixed bug where anonymous user can't view work page

pull/1/head
eric 2011-11-26 17:09:33 -05:00
parent e38d78ecc3
commit f96b5e4637
2 changed files with 6 additions and 2 deletions

View File

@ -157,6 +157,7 @@ $(document).ready(function(){
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
{% if not user.is_anonymous %}
{% if request.user.rights_holder.all.count %} {% if request.user.rights_holder.all.count %}
<h4> Claim this work:</h4> <h4> Claim this work:</h4>
<form method="GET" action="{% url claim %}"> <form method="GET" action="{% url claim %}">
@ -167,6 +168,7 @@ $(document).ready(function(){
<input type="submit" name="submit" value="Claim" id="submit"> <input type="submit" name="submit" value="Claim" id="submit">
</form> </form>
{% endif %} {% endif %}
{% endif %}
</div> </div>
</div> </div>
</div> </div>

View File

@ -59,8 +59,10 @@ def stub(request):
def work(request, work_id, action='display'): def work(request, work_id, action='display'):
work = get_object_or_404(models.Work, id=work_id) work = get_object_or_404(models.Work, id=work_id)
campaign = work.last_campaign() campaign = work.last_campaign()
if not request.user.is_anonymous():
claimform = UserClaimForm( request.user, data={'work':work_id, 'user': request.user.id}) claimform = UserClaimForm( request.user, data={'work':work_id, 'user': request.user.id})
else:
claimform = None
if campaign: if campaign:
q = Q(campaign=campaign) | Q(campaign__isnull=True) q = Q(campaign=campaign) | Q(campaign__isnull=True)
premiums = models.Premium.objects.filter(q) premiums = models.Premium.objects.filter(q)