Skip to content

Commit

Permalink
Migration notification for v4.x #1037
Browse files Browse the repository at this point in the history
  • Loading branch information
dennissiemensma committed Jul 3, 2020
1 parent 23b2e54 commit a560779
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dsmr_frontend/migrations/0027_v215_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def migrate_forward(apps, schema_editor):
# If someone if using the v3-branch, we no longer require this migration. Code was removed in v3.
# If someone was using the v3-branch, we no longer require this migration. Code was removed in v3.
pass


Expand Down
37 changes: 37 additions & 0 deletions dsmr_frontend/migrations/0037_v3_12_0_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 2.2.9 on 2020-01-07 19:21

from django.db import migrations
from django.utils.translation import ugettext_lazy


def migrate_forward(apps, schema_editor):
import dsmr_frontend.services
import dsmr_backend.services.backend

if dsmr_backend.services.backend.is_recent_installation():
# Skip for new installations.
return

Notification = apps.get_model('dsmr_frontend', 'Notification')
Notification.objects.create(
message=dsmr_frontend.services.get_translated_string(text=ugettext_lazy(
'This is the final release on v3. Switching to v4 requires you to manually upgrade. '
'Click the link button for more information.'
)),
redirect_to='frontend:v4-upgrade-redirect'
)


def migrate_backward(apps, schema_editor):
pass


class Migration(migrations.Migration):

operations = [
migrations.RunPython(migrate_forward, migrate_backward),
]

dependencies = [
('dsmr_frontend', '0036_graphs_zoom'),
]
4 changes: 3 additions & 1 deletion dsmr_frontend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from dsmr_frontend.views.compare import Compare, CompareXhrSummary
from dsmr_frontend.views.export import Export, ExportAsCsv
from dsmr_frontend.views.status import Status, XhrUpdateChecker
from dsmr_frontend.views.generic import ChangelogRedirect, DocsRedirect, FeedbackRedirect, DonationsRedirect, XhrHeader
from dsmr_frontend.views.generic import ChangelogRedirect, DocsRedirect, FeedbackRedirect, DonationsRedirect, \
XhrHeader, V4UpgradeRedirect
from dsmr_frontend.views.energy_contracts import EnergyContracts
from dsmr_frontend.views.live_graphs import LiveGraphs, LiveXhrElectricityConsumption, LiveXhrGasConsumption, \
LiveXhrTemperature
Expand Down Expand Up @@ -55,6 +56,7 @@
path('docs-redirect', DocsRedirect.as_view(), name='docs-redirect'),
path('feedback-redirect', FeedbackRedirect.as_view(), name='feedback-redirect'),
path('donations-redirect', DonationsRedirect.as_view(), name='donations-redirect'),
path('v4-upgrade-redirect', V4UpgradeRedirect.as_view(), name='v4-upgrade-redirect'),

# Views requiring authentication.
path('configuration', Configuration.as_view(), name='configuration'),
Expand Down
8 changes: 7 additions & 1 deletion dsmr_frontend/views/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ def get(self, request):
class ReadTheDocsRedirectView(RedirectView):
permanent = False
subpage = None
branch = settings.DSMRREADER_MAIN_BRANCH
url = None

def get(self, request, *args, **kwargs):
self.url = 'https://dsmr-reader.readthedocs.io/{}/{}/{}'.format(
request.LANGUAGE_CODE, settings.DSMRREADER_MAIN_BRANCH, self.subpage
request.LANGUAGE_CODE, self.branch, self.subpage
)
return super(ReadTheDocsRedirectView, self).get(request, *args, **kwargs)

Expand All @@ -44,3 +45,8 @@ class FeedbackRedirect(ReadTheDocsRedirectView):

class DonationsRedirect(ReadTheDocsRedirectView):
subpage = 'donations.html'


class V4UpgradeRedirect(ReadTheDocsRedirectView):
subpage = 'faq/v4_upgrade.html'
branch = 'v4'
Binary file modified dsmrreader/locales/nl/LC_MESSAGES/django.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions dsmrreader/locales/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,9 @@ msgstr "DSMR-reader v3.4.0 (3/3): Grafieken die voorheen op het Dashboard stonde
msgid "You are using a MySQL database without timezone support. This may cause bugs. Please enable timezone support in your database, see: https://dev.mysql.com/doc/refman/en/mysql-tzinfo-to-sql.html"
msgstr "Je gebruikt een MySQL-database zonder ondersteuning voor tijdzones. Dit kan fouten veroorzaken. Zet ondersteuning voor tijdzones aan in je database, zie: https://dev.mysql.com/doc/refman/en/mysql-tzinfo-to-sql.html"

msgid "This is the final release on v3. Switching to v4 requires you to manually upgrade. Click the link button for more information."
msgstr "Dit is de laatste release van DSMR-reader versie 3. Om te wisselen naar DSMR-reader versie 4 zul je handmatig moeten upgraden. Klik op de linkknop voor meer informatie."

msgid "Application notification"
msgstr "Applicatienotificatie"

Expand Down
15 changes: 15 additions & 0 deletions dsmrreader/provisioning/downgrade/v3.12.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Dump for DSMR-reader v3.12
./manage.py migrate dsmr_api 0003_create_api_user
./manage.py migrate dsmr_backend 0014_verbose_field_translations
./manage.py migrate dsmr_backup 0011_remove_backupsettings_latest_backup
./manage.py migrate dsmr_consumption 0015_track_power_current
./manage.py migrate dsmr_datalogger 0022_three_month_retention
./manage.py migrate dsmr_frontend 0037_v3_12_0_release
./manage.py migrate dsmr_mindergas 0005_schedule_mindergas_export
./manage.py migrate dsmr_mqtt 0014_mqtt_telegram_defaults
./manage.py migrate dsmr_notification 0007_support_for_telegram
./manage.py migrate dsmr_pvoutput 0002_pvoutput_latest_sync
./manage.py migrate dsmr_stats 0014_day_total_cost_index
./manage.py migrate dsmr_weather 0006_schedule_weather_update

0 comments on commit a560779

Please sign in to comment.