From 96969fe37a3f589bbd0a9688979c7cd332cf5c1d Mon Sep 17 00:00:00 2001 From: Magnus Granberg Date: Sun, 2 Aug 2015 01:02:22 +0200 Subject: add repoman full support --- python/tbc_www/models.py | 13 +++++++++- python/tbc_www/views.py | 30 ++++++++++++++++------ python/templates/includes/frontpage/new_repoman_qa | 16 +++++++++--- .../templates/pages/packages/category/index.html | 6 ++++- python/templates/pages/packages/ebuilds/index.html | 3 +++ 5 files changed, 54 insertions(+), 14 deletions(-) diff --git a/python/tbc_www/models.py b/python/tbc_www/models.py index 2cb327a..efdc13a 100644 --- a/python/tbc_www/models.py +++ b/python/tbc_www/models.py @@ -89,7 +89,7 @@ class BuildLogs(models.Model): def __str__(self): return '%s %s %s %s %s %s %s' % (self.BuildLogId, self.EbuildId, self.Fail, self.SummeryText, self.LogHash, self.BugId, self.TimeStamp) -class BuildLogsRepomanQa(models.Model): +class BuildLogsQa(models.Model): Id = models.IntegerField(primary_key=True, db_column='id') BuildLogId = models.ForeignKey(BuildLogs, db_column='build_log_id') SummeryText = models.TextField(db_column='summery_text') @@ -98,6 +98,17 @@ class BuildLogsRepomanQa(models.Model): def __str__(self): return '%s %s %s' % (self.Id, self.BuildLogId, self.SummeryText) +class PackagesRepoman(models.Model): + Id = models.IntegerField(primary_key=True, db_column='id') + PackageId = models.ForeignKey(Packages, db_column='package_id') + RepomanText = models.TextField(db_column='repoman_text') + RepomanHash = models.CharField(max_length=100, db_column='repoman_hash') + TimeStamp = models.DateTimeField(db_column='time_stamp') + class Meta: + db_table = 'packages_repoman' + def __str__(self): + return '%s %s %s %s %s' % (self.Id, self.PackageId, self.RepomanText, self.RepomanHash, self.TimeStamp) + class ErrorsInfo(models.Model): ErrorId = models.IntegerField(primary_key=True, db_column='error_id') ErrorName = models.CharField(max_length=20, db_column='error_name') diff --git a/python/tbc_www/views.py b/python/tbc_www/views.py index 7e99671..ff9a201 100644 --- a/python/tbc_www/views.py +++ b/python/tbc_www/views.py @@ -5,9 +5,9 @@ from django.shortcuts import render, get_object_or_404, HttpResponseRedirect from django.conf import settings from gentoo_www.models import SiteSettings, Layout, Pages, SubPages, Sponsors, Posts -from tbc_www.models import EbuildsMetadata, BuildLogs, BuildJobs, BuildLogsRepomanQa, \ +from tbc_www.models import EbuildsMetadata, BuildLogs, BuildJobs, BuildLogsQa, \ BuildJobsUse, Categories, CategoriesMetadata, Packages, PackagesMetadata, Ebuilds, \ - Repos, EbuildsKeywords, BuildLogsErrors, EbuildsRestrictions, EbuildsIuse + Repos, EbuildsKeywords, BuildLogsErrors, EbuildsRestrictions, EbuildsIuse, PackagesRepoman import re def default_TmpDict(pagerequest): @@ -29,7 +29,7 @@ def default_TmpDict(pagerequest): def home(request): pagerequest = 'home' - Lines = 5 + Lines = 10 TmpDict = default_TmpDict(pagerequest) TmpDict['EM'] = EbuildsMetadata.objects.filter(Revision = '1.1').order_by('-Id')[:Lines] alist = [] @@ -77,7 +77,8 @@ def home(request): adict2['title'] = adict2['title'] + "\n" adict[BJ.BuildJobId] = adict2 TmpDict['BJ'] = adict - TmpDict['RM'] = BuildLogsRepomanQa.objects.order_by('-Id')[:Lines] + TmpDict['QA_tmp'] = BuildLogsQa.objects.order_by('-Id')[:Lines/2] + TmpDict['PR_tmp'] = PackagesRepoman.objects.order_by('-Id')[:Lines/2] return render(request, 'pages/' + pagerequest + '/index.html', TmpDict) def categories(request): @@ -107,6 +108,12 @@ def packages(request, category_id): adict['Package'] = PM.PackageId.Package adict['Descriptions'] = PM.Descriptions adict['Changlog'] =PM.Changlog + try: + PackagesRepoman.objects.get(PackageId__PackageId = PM.PackageId.PackageId) + except PackagesRepoman.DoesNotExist as e: + adict['Repoman'] = False + else: + adict['Repoman'] = True ebuilds = [] for E in Ebuilds.objects.filter(Active = True).filter(PackageId__Package = PM.PackageId.Package): ebuilds.append(E.Version + '::' + E.PackageId.RepoId.Repo + '\n') @@ -119,11 +126,16 @@ def packages(request, category_id): def ebuilds(request, package_id): pagerequest = 'packages' TmpDict = default_TmpDict(pagerequest) - P = get_object_or_404(PackagesMetadata, PackageId__PackageId = package_id) + P = get_object_or_404(PackagesMetadata, PackageId__PackageId = package_id) TmpDict['P'] = P TmpDict['EM_tmp'] = EbuildsMetadata.objects.filter(EbuildId__Active = True).filter(EbuildId__PackageId__Package = P.PackageId.Package) TmpDict['EK_tmp'] = EbuildsKeywords.objects.filter(EbuildId__Active = True).filter(EbuildId__PackageId__Package = P.PackageId.Package) - + try: + PackagesRepoman.objects.get(PackageId__PackageId = package_id) + except PackagesRepoman.DoesNotExist as e: + TmpDict['PR'] = False + else: + TmpDict['PR'] = True return render(request, 'pages/' + pagerequest + '/ebuilds/index.html', TmpDict) def ebuild(request, ebuild_id): @@ -188,12 +200,14 @@ def new_main(request): adict2['title'] = adict2['title'] + "\n" adict[BJ.BuildJobId] = adict2 TmpDict['BJ'] = adict - TmpDict['RM'] = BuildLogsRepomanQa.objects.order_by('-Id')[:Lines] + TmpDict['QA_tmp'] = BuildLogsQa.objects.order_by('-Id')[:Lines/2] + TmpDict['PR_tmp'] = PackagesRepoman.objects.order_by('-Id')[:Lines/2] return render(request, 'pages/' + pagerequest + '/index.html', TmpDict) def new_repomanqa(request): pagerequest = 'new' Lines = 30 TmpDict = default_TmpDict(pagerequest) - TmpDict['RM_tmp'] = BuildLogsRepomanQa.objects.order_by('-Id')[:Lines] + TmpDict['QA_tmp'] = BuildLogsQa.objects.order_by('-Id')[:Lines/2] + TmpDict['PR_tmp'] = PackagesRepoman.objects.order_by('-Id')[:Lines/2] return render(request, 'pages/' + pagerequest + '/repomanqa/index.html', TmpDict) diff --git a/python/templates/includes/frontpage/new_repoman_qa b/python/templates/includes/frontpage/new_repoman_qa index 1999362..61ac691 100644 --- a/python/templates/includes/frontpage/new_repoman_qa +++ b/python/templates/includes/frontpage/new_repoman_qa @@ -1,10 +1,18 @@ - {% for R in RM %} + {% for QA in QA_tmp %} - - + + + {% endfor %} + {% for PR in PR_tmp %} + + + {% endfor %}
- {{ R.BuildLogId.EbuildId.PackageId.CategoryId.Category }}/{{ R.BuildLogId.EbuildId.PackageId.Package }}-{{ R.BuildLogId.EbuildId.Version }}::{{ R.BuildLogId.EbuildId.PackageId.RepoId.Repo }} + + {{ QA.BuildLogId.EbuildId.PackageId.CategoryId.Category }}/{{ QA.BuildLogId.EbuildId.PackageId.Package }}-{{ QA.BuildLogId.EbuildId.Version }}::{{ QA.BuildLogId.EbuildId.PackageId.RepoId.Repo }}

{{ R.SummeryText|truncatewords:3 }}

{{ QA.SummeryText|truncatewords:3 }}

+ {{ PR.PackageId.CategoryId.Category }}/{{ PR.PackageId.Package }}::{{ PR.PackageId.RepoId.Repo }} +

{{ PR.RepomanText|truncatewords:3 }}

\ No newline at end of file diff --git a/python/templates/pages/packages/category/index.html b/python/templates/pages/packages/category/index.html index 2f2b6f2..8cc402d 100644 --- a/python/templates/pages/packages/category/index.html +++ b/python/templates/pages/packages/category/index.html @@ -12,7 +12,11 @@

{{ PM.Descriptions }}

-

Versions

+

Versions + {% if PM.Repoman %} + Repoman + {% endif %} +

diff --git a/python/templates/pages/packages/ebuilds/index.html b/python/templates/pages/packages/ebuilds/index.html index f8e1b4e..10cca76 100644 --- a/python/templates/pages/packages/ebuilds/index.html +++ b/python/templates/pages/packages/ebuilds/index.html @@ -23,5 +23,8 @@ {% endfor %} + {% if PR %} + Repoman + {% endif %} {% endblock %} \ No newline at end of file -- cgit v1.2.3-65-gdbad