views.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright 2014 The Distro Tracker Developers
  2. # See the COPYRIGHT file at the top-level directory of this distribution and
  3. # at http://deb.li/DTAuthors
  4. #
  5. # This file is part of Distro Tracker. It is subject to the license terms
  6. # in the LICENSE file found in the top-level directory of this
  7. # distribution and at http://deb.li/DTLicense. No part of Distro Tracker,
  8. # including this file, may be copied, modified, propagated, or distributed
  9. # except according to the terms contained in the LICENSE file.
  10. from django.shortcuts import render
  11. from django.shortcuts import get_list_or_404, get_object_or_404
  12. from distro_tracker.core.models import RepositoryRelation
  13. from distro_tracker.core.models import Repository
  14. from .utils import compare_repositories, CATEGORIES_VERSION_COMPARISON
  15. def index(request):
  16. list_derivatives = get_list_or_404(RepositoryRelation, name='derivative')
  17. return render(request, 'derivative/index.html',
  18. {'list_derivatives': list_derivatives})
  19. def comparison(request, distribution):
  20. repository = get_object_or_404(Repository, shorthand=distribution)
  21. relation = get_object_or_404(repository.relations, name='derivative')
  22. pkglist = compare_repositories(repository, relation.target_repository)
  23. context = {
  24. 'pkglist': pkglist,
  25. 'categories': CATEGORIES_VERSION_COMPARISON,
  26. 'repository': repository,
  27. 'target_repository': relation.target_repository,
  28. }
  29. return render(request, 'derivative/comparison.html', context)