views.py 666 B

1234567891011121314151617181920212223242526
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.shortcuts import render
  4. from django.contrib.auth.decorators import login_required
  5. from .models import Item, Loan
  6. @login_required
  7. def loan_list(request):
  8. view = 'old' if 'old' in request.GET else ''
  9. if view == 'old':
  10. loans = request.user.loans.finished().order_by('-loan_date_end')
  11. else:
  12. loans = request.user.loans.running()
  13. return render(request, 'hardware_provisioning/list.html', {
  14. 'loans': loans,
  15. 'view': view,
  16. })
  17. @login_required
  18. def loan_detail(request, pk):
  19. return render(request, 'hardware_provisioning/detail.html', {})