Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger(a)uvena.de>
Committer: Enrico Tröger <enrico.troeger(a)uvena.de>
Date: Sun, 14 Jul 2019 12:07:24 UTC
Commit: aa4dae2b8fa179042e72fce0b8e669eff7c645b4
https://github.com/geany/www.geany.org/commit/aa4dae2b8fa179042e72fce0b8e66…
Log Message:
-----------
Delay sitemap registration to actual app loading
The previous attempt caused errors on "manage.py migrate" on an empty
database because Site objects were loaded in the Sitemap registry on
module import but the Sites framework database table was not created
yet.
So delay the sitemap registration to actual app loading to fix this
race condition.
Modified Paths:
--------------
geany/settings.py
latest_version/apps.py
latest_version/urls.py
news/apps.py
news/urls.py
nightlybuilds/apps.py
pastebin/apps.py
pastebin/urls.py
static_docs/apps.py
Modified: geany/settings.py
14 lines changed, 7 insertions(+), 7 deletions(-)
===================================================================
@@ -318,17 +318,17 @@
"mezzanine.twitter",
# we
- "geany",
- "news",
- "latest_version",
- "static_docs",
- "pastebin", # pastebin.geany.org
- "nightlybuilds", # nightly.geany.org
+ "geany.apps.GeanyAppConfig",
+ "news.apps.NewsAppConfig",
+ "latest_version.apps.LatestVersionAppConfig",
+ "static_docs.apps.StaticDocsAppConfig",
+ "pastebin.apps.PastebinAppConfig",
+ "nightlybuilds.apps.NightlyBuildsAppConfig",
# 3rd party
"honeypot", # for pastebin
"mezzanine_pagedown",
- "mezzanine_sync_pages",
+ "mezzanine_sync_pages.apps.MezzanineSyncPagesAppConfig",
)
# List of middleware classes to use. Order is important; in the request phase,
Modified: latest_version/apps.py
27 lines changed, 27 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,27 @@
+# coding: utf-8
+# LICENCE: This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from django.apps import AppConfig
+
+
+class LatestVersionAppConfig(AppConfig):
+ name = 'latest_version'
+ verbose_name = "LatestVersion"
+
+ # ----------------------------------------------------------------------
+ def ready(self):
+ # register our urlpatterns to the global sitemap generator
+ from geany.sitemaps import sitemap_registry, StaticSitemap
+ from latest_version.urls import urlpatterns
+ sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['latest_version_legacy'])
Modified: latest_version/urls.py
5 lines changed, 0 insertions(+), 5 deletions(-)
===================================================================
@@ -15,8 +15,6 @@
from django.conf.urls import url
from django.views.generic import TemplateView
-from geany.sitemaps import sitemap_registry, StaticSitemap
-
urlpatterns = ( # pylint: disable=invalid-name
# special url for the UpdateChecker Geany plugin
@@ -30,6 +28,3 @@
TemplateView.as_view(template_name='latest_version.txt', content_type='text/plain'),
name='latest_version_legacy'),
)
-
-# register our urlpatterns to the global sitemap generator
-sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['latest_version_legacy'])
Modified: news/apps.py
28 lines changed, 28 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,28 @@
+# coding: utf-8
+# LICENCE: This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from django.apps import AppConfig
+
+
+class NewsAppConfig(AppConfig):
+ name = 'news'
+ verbose_name = "News"
+
+ # ----------------------------------------------------------------------
+ def ready(self):
+ # register our urlpatterns to the global sitemap generator
+ from geany.sitemaps import sitemap_registry
+ from news.sitemaps import NewsPostSitemap
+ from news.urls import urlpatterns
+ sitemap_registry.add(NewsPostSitemap, urlpatterns)
Modified: news/urls.py
5 lines changed, 0 insertions(+), 5 deletions(-)
===================================================================
@@ -14,9 +14,7 @@
from django.conf.urls import url
-from geany.sitemaps import sitemap_registry
from news.feeds import LatestNewsPostsFeed
-from news.sitemaps import NewsPostSitemap
from news.views import NewsDetailView, NewsListView
@@ -25,6 +23,3 @@
url(r'^feed/$', LatestNewsPostsFeed(), name='news_feed'),
url(r'^(?P<newspost_slug>.+)/$', NewsDetailView.as_view(), name='news_detail'),
)
-
-# register our urlpatterns to the global sitemap generator
-sitemap_registry.add(NewsPostSitemap, urlpatterns)
Modified: nightlybuilds/apps.py
20 lines changed, 20 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,20 @@
+# coding: utf-8
+# LICENCE: This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from django.apps import AppConfig
+
+
+class NightlyBuildsAppConfig(AppConfig):
+ name = 'nightlybuilds'
+ verbose_name = "Nightly Builds"
Modified: pastebin/apps.py
27 lines changed, 27 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,27 @@
+# coding: utf-8
+# LICENCE: This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from django.apps import AppConfig
+
+
+class PastebinAppConfig(AppConfig):
+ name = 'pastebin'
+ verbose_name = "Pastebin"
+
+ # ----------------------------------------------------------------------
+ def ready(self):
+ # Sitemap framework
+ from geany.sitemaps import sitemap_registry, StaticSitemap
+ from pastebin.urls import urlpatterns
+ sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['snippet_api'])
Modified: pastebin/urls.py
5 lines changed, 0 insertions(+), 5 deletions(-)
===================================================================
@@ -16,7 +16,6 @@
from django.views.decorators.cache import never_cache
from django.views.generic.base import TemplateView
-from geany.sitemaps import sitemap_registry, StaticSitemap
from pastebin.views import (
LatestSnippetsView,
SnippetAPIView,
@@ -54,7 +53,3 @@
SnippetDetailRawView.as_view(),
name='snippet_details_raw'),
)
-
-
-# Sitemap framework
-sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['snippet_api'])
Modified: static_docs/apps.py
20 lines changed, 20 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,20 @@
+# coding: utf-8
+# LICENCE: This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from django.apps import AppConfig
+
+
+class StaticDocsAppConfig(AppConfig):
+ name = 'static_docs'
+ verbose_name = "Static Docs"
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger(a)uvena.de>
Committer: Enrico Tröger <enrico.troeger(a)uvena.de>
Date: Sat, 13 Jul 2019 14:19:13 UTC
Commit: ac5d8dc1b5cfc55bc394f776fb28ac25977d73f0
https://github.com/geany/www.geany.org/commit/ac5d8dc1b5cfc55bc394f776fb28a…
Log Message:
-----------
Dump only the last nightly build per target
When dumping the nightly build database limit the dump to the last
build per target. The previous attempt of dumping the builds of the
last seven days could lead to corrupt references between
builds and targets.
Also fix unintended nested level in the combined JSON dump.
Modified Paths:
--------------
geany/management/commands/dump_database.py
Modified: geany/management/commands/dump_database.py
15 lines changed, 7 insertions(+), 8 deletions(-)
===================================================================
@@ -12,13 +12,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from datetime import timedelta
from json import dump, load
from os import unlink
from django.contrib.auth.hashers import make_password
from django.core.management import BaseCommand, call_command
-from django.utils import timezone
+from django.db.models import F
from nightlybuilds.models import NightlyBuild
@@ -88,12 +87,12 @@ def _remove_sensitive_information_from_dump(self):
# ----------------------------------------------------------------------
def _dump_nightly_builds_database(self):
- # dump nightly builds database but limit the data to the last week
- # to reduce dump size
- now_a_week_ago = timezone.now() - timedelta(days=7)
+ # query the last nightly build for each build target for the dump
+ # (dumping all builds would be too large)
queryset = NightlyBuild.objects.\
- filter(build_date__gte=now_a_week_ago).\
- only('nightly_build_id')
+ prefetch_related('nightly_build_target').\
+ filter(nightly_build_target__last_nightly_build_id=F('nightly_build_id')).\
+ order_by('nightly_build_target__project', 'nightly_build_target__identifier')
pks = [str(item.nightly_build_id) for item in queryset]
database_nightlybuilds_filename = 'tmp_database_nightlybuilds.json'
@@ -122,7 +121,7 @@ def _dump_nightly_builds_database(self):
for filename in filenames:
with open(filename) as infile:
data = load(infile)
- records.append(data)
+ records.extend(data)
dump(records, output, indent=2)
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).