From 5b42b2fda7afb18c8893bd1b2627f6631e8caba5 Mon Sep 17 00:00:00 2001 From: Magnus Granberg Date: Thu, 16 Jul 2015 15:45:08 +0200 Subject: add the new home page for tbc --- python/gentoo_main/urls.py | 3 +- python/tbc_www/__init__.py | 0 python/tbc_www/models.py | 111 +++++++++++++++++++++ python/tbc_www/router.py | 30 ++++++ python/tbc_www/views.py | 37 +++++++ python/templates/includes/frontpage/glsa | 17 ---- python/templates/includes/frontpage/new_build_req | 8 ++ python/templates/includes/frontpage/new_logs | 9 ++ python/templates/includes/frontpage/new_packages | 10 ++ python/templates/includes/frontpage/new_repoman_qa | 10 ++ python/templates/includes/frontpage/packages | 8 -- python/templates/includes/frontpage/planet | 8 -- python/templates/includes/frontpage/wiki | 8 -- python/templates/pages/home/index.html | 42 ++------ 14 files changed, 224 insertions(+), 77 deletions(-) create mode 100644 python/tbc_www/__init__.py create mode 100644 python/tbc_www/models.py create mode 100644 python/tbc_www/router.py create mode 100644 python/tbc_www/views.py delete mode 100644 python/templates/includes/frontpage/glsa create mode 100644 python/templates/includes/frontpage/new_build_req create mode 100644 python/templates/includes/frontpage/new_logs create mode 100644 python/templates/includes/frontpage/new_packages create mode 100644 python/templates/includes/frontpage/new_repoman_qa delete mode 100644 python/templates/includes/frontpage/packages delete mode 100644 python/templates/includes/frontpage/planet delete mode 100644 python/templates/includes/frontpage/wiki diff --git a/python/gentoo_main/urls.py b/python/gentoo_main/urls.py index 5380bea..6cead02 100644 --- a/python/gentoo_main/urls.py +++ b/python/gentoo_main/urls.py @@ -3,7 +3,6 @@ from django.conf.urls import patterns, include, url -urlpatterns = patterns('gentoo_www.views', +urlpatterns = patterns('tbc_www.views', (r'^home/$', 'home'), - (r'^downloads/$', 'downloads'), ) diff --git a/python/tbc_www/__init__.py b/python/tbc_www/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python/tbc_www/models.py b/python/tbc_www/models.py new file mode 100644 index 0000000..b51e154 --- /dev/null +++ b/python/tbc_www/models.py @@ -0,0 +1,111 @@ +# Copyright 1998-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +from django.db import models + +class Categories(models.Model): + CategoryId = models.IntegerField(primary_key=True, db_column='category_id') + Category = models.CharField(max_length=150, db_column='category') + Active = models.BooleanField(db_column='active') + TimeStamp = models.DateTimeField(db_column='time_stamp') + class Meta: + db_table = 'categories' + def __str__(self): + return '%s %s %s %s' % (self.CategoryId, self.Category, self.Active, self.TimeStamp) + +class Repos(models.Model): + RepoId = models.IntegerField(primary_key=True, db_column='repo_id') + Repo = models.CharField(max_length=100, db_column='repo') + class Meta: + db_table = 'repos' + def __str__(self): + return '%s %s' % (self.RepoId, self.Repo) + +class Packages(models.Model): + PackageId = models.IntegerField(primary_key=True, db_column='package_id') + CategoryId = models.ForeignKey(Categories, db_column='category_id') + Package = models.CharField(max_length=150, db_column='package') + RepoId = models.ForeignKey(Repos, db_column='repo_id') + Checksum = models.CharField(max_length=100, db_column='checksum') + Active = models.BooleanField(db_column='active') + TimeStamp = models.DateTimeField(db_column='time_stamp') + class Meta: + db_table = 'packages' + def __str__(self): + return '%s %s %s %s %s %s %s' % (self.PackageId, self.CategoryId, self.Package, self.RepoId, self.Checksum, self.Active, self.TimeStamp) + +class Ebuilds(models.Model): + EbuildId = models.IntegerField(primary_key=True, db_column='ebuild_id') + PackageId = models.ForeignKey(Packages, db_column='package_id') + Version = models.CharField(max_length=150, db_column='version') + Checksum = models.CharField(max_length=100, db_column='checksum') + Active = models.BooleanField(db_column='active') + TimeStamp = models.DateTimeField(db_column='time_stamp') + class Meta: + db_table = 'ebuilds' + def __str__(self): + return '%s %s %s %s %s %s' % (self.EbuildId, self.PackageId, self.Version, self.Checksum, self.Active, self.TimeStamp) + +class EbuildsMetadata(models.Model): + Id = models.IntegerField(primary_key=True, db_column='id') + EbuildId = models.ForeignKey(Ebuilds, db_column='ebuild_id') + Revision = models.CharField(max_length=30, db_column='revision') + Descriptions = models.CharField(max_length=200, db_column='descriptions') + class Meta: + db_table = 'ebuilds_metadata' + def __str__(self): + return '%s %s %s %s' % (self.Id, self.EbuildId, self.Revision, self.Descriptions) + +class BuildLogs(models.Model): + BuildLogId = models.IntegerField(primary_key=True, db_column='build_log_id') + EbuildId = models.ForeignKey(Ebuilds, db_column='ebuild_id') + Fail = models.BooleanField(db_column='fail') + SummeryText = models.TextField(db_column='summery_text') + LogHash = models.CharField(max_length=100, db_column='log_hash') + BugId = models.IntegerField( db_column='bug_id') + TimeStamp = models.DateTimeField(db_column='time_stamp') + class Meta: + db_table = 'build_logs' + 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): + 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') + class Meta: + db_table = 'build_logs_repoman' + def __str__(self): + return '%s %s %s' % (self.Id, self.BuildLogId, self.SummeryText) + +class Setups(models.Model): + SetupId = models.AutoField(primary_key=True, db_column='setup_id') + Setup = models.CharField(max_length=100, db_column='setup') + Profile = models.CharField(max_length=150, db_column='profile') + class Meta: + db_table = 'setups' + def __str__(self): + return '%s %s %s' % (self.SetupId, self.Setup, self.Profile) + +class Configs(models.Model): + ConfigId = models.AutoField(primary_key=True, db_column='config_id') + HostName = models.CharField(max_length=150, db_column='hostname') + SetupId = models.ForeignKey(Setups, db_column='setup_id') + DefaultConfig = models.BooleanField(db_column='default_config') + class Meta: + db_table = 'configs' + def __str__(self): + return '%s %s %s %s' % (self.ConfigId, self.HostName, self.SetupId, self.DefaultConfig) + +class BuildJobs(models.Model): + BuildJobId = models.AutoField(primary_key=True, db_column='build_job_id') + EbuildId = models.ForeignKey(Ebuilds, db_column='ebuild_id') + ConfigId = models.ForeignKey(Configs, db_column='config_id') + Status = models.CharField(max_length=21, db_column='status') + BuildNow = models.BooleanField(db_column='build_now') + RemoveBin = models.BooleanField(db_column='removebin') + TimeStamp = models.DateTimeField(db_column='time_stamp') + class Meta: + db_table = 'build_jobs' + def __str__(self): + return '%s %s %s %s %s %s %s' % (self.BuildJobId, self.EbuildId, self.ConfigId, self.Status, self.BuildNow, self.RemoveBin, self.TimeStamp) diff --git a/python/tbc_www/router.py b/python/tbc_www/router.py new file mode 100644 index 0000000..aa16759 --- /dev/null +++ b/python/tbc_www/router.py @@ -0,0 +1,30 @@ +# Copyright 1998-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +class TBCRouter(object): + def db_for_read(self, model, **hints): + "Point all operations on zobcs models to 'zobcs'" + if model._meta.app_label == 'tbc_www': + return 'zobcs' + return 'default' + + def db_for_write(self, model, **hints): + "Point all operations on zobcs models to 'zobcs'" + if model._meta.app_label == 'tbc_www': + return 'zobcs' + return 'default' + + def allow_relation(self, obj1, obj2, **hints): + "Allow any relation if a both models in zobcs app" + if obj1._meta.app_label == 'tbc_www' and obj2._meta.app_label == 'tbc_www': + return True + # Allow if neither is zobcs app + elif 'tbc_www' not in [obj1._meta.app_label, obj2._meta.app_label]: + return True + return False + + def allow_migrate(self, db, model): + if db == 'zobcs' or model._meta.app_label == "tbc_www": + return False # we're not using syncdb on our legacy database + else: # but all other models/databases are fine + return True diff --git a/python/tbc_www/views.py b/python/tbc_www/views.py new file mode 100644 index 0000000..58f186e --- /dev/null +++ b/python/tbc_www/views.py @@ -0,0 +1,37 @@ +# Copyright 1998-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +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 + +import re + +def default_TmpDict(pagerequest): + site = get_object_or_404(SiteSettings) + page = get_object_or_404(Pages, nav1 = pagerequest) + pages = Pages.objects.all() + if page.SubMenu: + subpages = SubPages.objects.filter(PageId = page.PageId) + else: + subpages = False + contact = get_object_or_404(SubPages, nav2 = 'contact') + TmpDict = {'site' : site} + TmpDict['page'] = page + TmpDict['pages'] = pages + TmpDict['subpages'] = subpages + TmpDict['contact'] = contact + TmpDict['smappages'] = SubPages.objects.all() + return TmpDict + +def home(request): + pagerequest = 'home' + Lines = 10 + TmpDict = default_TmpDict(pagerequest) + TmpDict['EM'] = EbuildsMetadata.objects.filter(Revision = '1.1').order_by('-Id')[:Lines] + TmpDict['BL'] = BuildLogs.objects.order_by('-TimeStamp')[:Lines] + TmpDict['BJ'] = BuildJobs.objects.order_by('-TimeStamp')[:Lines] + TmpDict['RM'] = BuildLogsRepomanQa.objects.order_by('-Id')[:Lines] + return render(request, 'pages/' + pagerequest + '/index.html', TmpDict) diff --git a/python/templates/includes/frontpage/glsa b/python/templates/includes/frontpage/glsa deleted file mode 100644 index a2ed049..0000000 --- a/python/templates/includes/frontpage/glsa +++ /dev/null @@ -1,17 +0,0 @@ - - {% for advisory in glsaposts %} - - - - - - {% endfor %} -
GLSA {{ advisory.id }}{{ advisory.title }} - {% if advisory.severity == 'high' %} - high - {% elif advisory.severity == 'low' %} - low - {% else %} - normal - {% endif %} -
\ No newline at end of file diff --git a/python/templates/includes/frontpage/new_build_req b/python/templates/includes/frontpage/new_build_req new file mode 100644 index 0000000..23b6f2d --- /dev/null +++ b/python/templates/includes/frontpage/new_build_req @@ -0,0 +1,8 @@ + + {% for J in BJ %} + + + + + {% endfor %} +
{{ J.EbuildId.PackageId.CategoryId.Category }}/{{ J.EbuildId.PackageId.Package }}-{{ J.EbuildId.Version }}::{{ J.EbuildId.PackageId.RepoId.Repo }}
\ No newline at end of file diff --git a/python/templates/includes/frontpage/new_logs b/python/templates/includes/frontpage/new_logs new file mode 100644 index 0000000..9480155 --- /dev/null +++ b/python/templates/includes/frontpage/new_logs @@ -0,0 +1,9 @@ + + {% for B in BL %} + + + + + {% endfor %} +
+ {{ B.EbuildId.PackageId.CategoryId.Category }}/{{ B.EbuildId.PackageId.Package }}-{{ B.EbuildId.Version }}::{{ B.EbuildId.PackageId.RepoId.Repo }}

{{ B.SummeryText|truncatewords:3 }}

\ No newline at end of file diff --git a/python/templates/includes/frontpage/new_packages b/python/templates/includes/frontpage/new_packages new file mode 100644 index 0000000..7de11c0 --- /dev/null +++ b/python/templates/includes/frontpage/new_packages @@ -0,0 +1,10 @@ + + {% for E in EM %} + + + + + {% endfor %} +
+ + {{ E.EbuildId.PackageId.CategoryId.Category }}/{{ E.EbuildId.PackageId.Package }}-{{ E.EbuildId.Version }}::{{ E.EbuildId.PackageId.RepoId.Repo }}

{{ E.Descriptions }}

\ No newline at end of file diff --git a/python/templates/includes/frontpage/new_repoman_qa b/python/templates/includes/frontpage/new_repoman_qa new file mode 100644 index 0000000..1999362 --- /dev/null +++ b/python/templates/includes/frontpage/new_repoman_qa @@ -0,0 +1,10 @@ + + {% for R in RM %} + + + + + {% endfor %} +
+ {{ R.BuildLogId.EbuildId.PackageId.CategoryId.Category }}/{{ R.BuildLogId.EbuildId.PackageId.Package }}-{{ R.BuildLogId.EbuildId.Version }}::{{ R.BuildLogId.EbuildId.PackageId.RepoId.Repo }} +

{{ R.SummeryText|truncatewords:3 }}

\ No newline at end of file diff --git a/python/templates/includes/frontpage/packages b/python/templates/includes/frontpage/packages deleted file mode 100644 index 710dec4..0000000 --- a/python/templates/includes/frontpage/packages +++ /dev/null @@ -1,8 +0,0 @@ - - {% for post in packageposts %} - - - - - {% endfor %} -
{{ post.atom_p }}{{ post.description }}
\ No newline at end of file diff --git a/python/templates/includes/frontpage/planet b/python/templates/includes/frontpage/planet deleted file mode 100644 index 7f884d2..0000000 --- a/python/templates/includes/frontpage/planet +++ /dev/null @@ -1,8 +0,0 @@ - - {% for post in planetposts %} - - - - - {% endfor %} -
{{ post.author }}{{ post.title }}
\ No newline at end of file diff --git a/python/templates/includes/frontpage/wiki b/python/templates/includes/frontpage/wiki deleted file mode 100644 index e9efc28..0000000 --- a/python/templates/includes/frontpage/wiki +++ /dev/null @@ -1,8 +0,0 @@ - - {% for post in wikiposts %} - - - - - {% endfor %} -
{{ post.title }}started by {{ post.author }}
\ No newline at end of file diff --git a/python/templates/pages/home/index.html b/python/templates/pages/home/index.html index 9e40877..d2b0ff7 100644 --- a/python/templates/pages/home/index.html +++ b/python/templates/pages/home/index.html @@ -1,54 +1,28 @@ {% extends "layout/base.html" %} {% block content %} -{% include "includes/hero-section/start" with class_include="emergehdr" %} -
-
-

- Welcome to Gentoo, a flexible, source-based Linux distribution that becomes just about any system you need—and much more. -

-
- -
-{% include "includes/hero-section/end" %} -{% include "includes/frontpage/news" %} -
-
-

Developer Blogs live from Planet Gentoo

- {% include "includes/frontpage/planet" %} +

New Packages more at the New Packages

+ {% include "includes/frontpage/new_packages" %}
-

Security Advisories from our Security database

- {% include "includes/frontpage/glsa" %} +

New Logs more at the New Logs

+ {% include "includes/frontpage/new_logs" %}
-

New Packages more at the Gentoo Packages database

- {% include "includes/frontpage/packages" %} +

New Build Requests more at the New Build Requests

+ {% include "includes/frontpage/new_build_req" %}
-

Fresh Documentation on the Gentoo Wiki

- {% include "includes/frontpage/wiki" %} +

New Repoman or QA's on the New Repoman or QA's

+ {% include "includes/frontpage/new_repoman_qa" %}

- {% endblock %} \ No newline at end of file -- cgit v1.2.3-65-gdbad