Skip to content

Commit

Permalink
add shared contribution_at field
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Apr 25, 2024
1 parent 4af1801 commit 7897bf1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions georiviere/contribution/migrations/0018_auto_20240425_1328.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.1.14 on 2024-04-25 13:28

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('contribution', '0017_auto_20240423_1542'),
]

operations = [
migrations.AlterModelOptions(
name='customcontribution',
options={'ordering': ('-contributed_at',), 'verbose_name': 'Custom contribution', 'verbose_name_plural': 'Custom contributions'},
),
migrations.AddField(
model_name='customcontribution',
name='contributed_at',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='Contributed at'),
),
]
3 changes: 3 additions & 0 deletions georiviere/contribution/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.core.mail import mail_managers
from django.template.loader import render_to_string
from django.utils.text import slugify
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from geotrek.common.mixins import BasePublishableMixin, TimeStampedModelMixin
from geotrek.common.utils import classproperty
Expand Down Expand Up @@ -842,12 +843,14 @@ class CustomContribution(TimeStampedModelMixin, models.Model):
related_name="custom_contributions",
on_delete=models.PROTECT,
)
contributed_at = models.DateTimeField(verbose_name=_("Contributed at"), default=now)
validated = models.BooleanField(default=False, verbose_name=_("Validated"))
objects = CustomContributionManager()

class Meta:
verbose_name = _("Custom contribution")
verbose_name_plural = _("Custom contributions")
ordering = ('-contributed_at',)

def __str__(self):
return f"{self.custom_type.label} - {self.pk}"

0 comments on commit 7897bf1

Please sign in to comment.