Compare commits
No commits in common. "938a96afbfae17e0f1d7befd1c6e94b16c746d24" and "830d33b0c0ffeaa88a17a0802bab714120bce8da" have entirely different histories.
938a96afbf
...
830d33b0c0
@ -38,7 +38,13 @@ def home_view(request: HttpRequest):
|
|||||||
user_teams = user.shared_teams
|
user_teams = user.shared_teams
|
||||||
|
|
||||||
# Fetch the four newest active and published ServerMessages
|
# Fetch the four newest active and published ServerMessages
|
||||||
msgs = ServerMessage.get_current_news()[:3]
|
msgs = ServerMessage.objects.filter(
|
||||||
|
is_active=True,
|
||||||
|
publish_on__lte=now,
|
||||||
|
unpublish_on__gte=now,
|
||||||
|
).order_by(
|
||||||
|
"-publish_on"
|
||||||
|
)[:3]
|
||||||
|
|
||||||
# First fetch all valid objects (undeleted, only newest versions)
|
# First fetch all valid objects (undeleted, only newest versions)
|
||||||
interventions = Intervention.objects.filter(
|
interventions = Intervention.objects.filter(
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 3.1.3 on 2023-03-24 06:20
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('news', '0002_auto_20220114_0936'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='servermessage',
|
|
||||||
name='unpublish_on',
|
|
||||||
field=models.DateTimeField(blank=True, null=True),
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,5 +1,4 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import timezone
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from konova.models import BaseResource
|
from konova.models import BaseResource
|
||||||
@ -23,7 +22,7 @@ class ServerMessage(BaseResource):
|
|||||||
body = models.TextField()
|
body = models.TextField()
|
||||||
is_active = models.BooleanField(default=True)
|
is_active = models.BooleanField(default=True)
|
||||||
publish_on = models.DateTimeField()
|
publish_on = models.DateTimeField()
|
||||||
unpublish_on = models.DateTimeField(null=True, blank=True)
|
unpublish_on = models.DateTimeField()
|
||||||
importance = models.CharField(max_length=100, choices=ServerMessageImportance.choices)
|
importance = models.CharField(max_length=100, choices=ServerMessageImportance.choices)
|
||||||
|
|
||||||
def save(self, user=None, *args, **kwargs):
|
def save(self, user=None, *args, **kwargs):
|
||||||
@ -35,24 +34,3 @@ class ServerMessage(BaseResource):
|
|||||||
self.modified = UserActionLogEntry.get_edited_action(user)
|
self.modified = UserActionLogEntry.get_edited_action(user)
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_current_news():
|
|
||||||
""" Getter for the most current news
|
|
||||||
|
|
||||||
Meaning the ones that are
|
|
||||||
* activated
|
|
||||||
* publish_on has passed
|
|
||||||
* unpublish_on (if set) has not been passed, yet
|
|
||||||
|
|
||||||
"""
|
|
||||||
now = timezone.now()
|
|
||||||
news = ServerMessage.objects.filter(
|
|
||||||
is_active=True,
|
|
||||||
publish_on__lte=now,
|
|
||||||
).exclude(
|
|
||||||
unpublish_on__lte=now,
|
|
||||||
).order_by(
|
|
||||||
"-publish_on"
|
|
||||||
)
|
|
||||||
return news
|
|
@ -20,7 +20,14 @@ def index_view(request: HttpRequest):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
template = "news/index.html"
|
template = "news/index.html"
|
||||||
news = ServerMessage.get_current_news()
|
now = timezone.now()
|
||||||
|
news = ServerMessage.objects.filter(
|
||||||
|
is_active=True,
|
||||||
|
publish_on__lte=now,
|
||||||
|
unpublish_on__gte=now
|
||||||
|
).order_by(
|
||||||
|
"-publish_on"
|
||||||
|
)
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"news": news,
|
"news": news,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
.netgis-attribution
|
.netgis-attribution
|
||||||
{
|
{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0mm;
|
left: 0mm;
|
||||||
bottom: 0mm;
|
bottom: 0mm;
|
||||||
padding: 1mm;
|
padding: 1mm;
|
||||||
background: rgba( 255, 255, 255, 0.5 );
|
background: rgba( 255, 255, 255, 0.5 );
|
||||||
|
@ -133,9 +133,7 @@ netgis.MapOpenLayers.prototype.initMap = function()
|
|||||||
view: this.view,
|
view: this.view,
|
||||||
pixelRatio: 1.0,
|
pixelRatio: 1.0,
|
||||||
moveTolerance: 5,
|
moveTolerance: 5,
|
||||||
controls: [
|
controls: []
|
||||||
new ol.control.ScaleLine(),
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user