Skip to content

Commit

Permalink
Merge pull request #4 from wanaryytel:master
Browse files Browse the repository at this point in the history
Made models translatable and added Estonian translations
  • Loading branch information
rivol committed Jun 11, 2018
2 parents 0482092 + 7a7bf30 commit 592089b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ coverage.xml
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py Makefile make.bat

graft tg_utils/locale
Binary file added tg_utils/locale/et/LC_MESSAGES/django.mo
Binary file not shown.
35 changes: 35 additions & 0 deletions tg_utils/locale/et/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (C) 2017
# This file is distributed under the same license as the tg_utils package.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 0.2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-02 22:56+0300\n"
"Last-Translator: Hanno Särg <[email protected]>\n"
"Language: Estonian (et-EE)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: tg_utils/models.py:17
msgid "Created by"
msgstr "Looja"

#: tg_utils/models.py:18 tg_utils/models.py:39
msgid "Created at"
msgstr "Loodi"

#: tg_utils/models.py:21
msgid "Closed by"
msgstr "Sulgeja"

#: tg_utils/models.py:22
msgid "Closed at"
msgstr "Sulgeti"

#: tg_utils/models.py:40 tg_utils/models.py:47
msgid "Updated at"
msgstr "Uuendati"
17 changes: 10 additions & 7 deletions tg_utils/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.conf import settings
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _

from .managers import NotClosedObjectsManager

Expand All @@ -12,11 +13,13 @@ class ClosableModel(models.Model):
Also provides default manager that automatically filters queryset to only include active (non-closed) items plus a
.close() function to mark objects as closed.
"""
created_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='+', null=True, blank=True)
created_at = models.DateTimeField(default=timezone.now)
created_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='+', null=True, blank=True,
verbose_name=_('Created by'))
created_at = models.DateTimeField(_('Created at'), default=timezone.now)

closed_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='+', null=True, blank=True)
closed_at = models.DateTimeField(null=True, blank=True)
closed_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='+', null=True, blank=True,
verbose_name=_('Closed by'))
closed_at = models.DateTimeField(_('Closed at'), null=True, blank=True)

all_objects = models.Manager()
objects = NotClosedObjectsManager()
Expand All @@ -33,15 +36,15 @@ def close(self, user):
class TimestampedModel(models.Model):
""" Provides self-updating created_at and updated_at fields.
"""
created_at = models.DateTimeField(default=timezone.now)
updated_at = models.DateTimeField(auto_now=True)
created_at = models.DateTimeField(_('Created at'), default=timezone.now)
updated_at = models.DateTimeField(_('Updated at'), auto_now=True)

class Meta:
abstract = True


class ClosableTimestampedModel(ClosableModel):
updated_at = models.DateTimeField(auto_now=True)
updated_at = models.DateTimeField(_('Updated at'), auto_now=True)

class Meta:
abstract = True

0 comments on commit 592089b

Please sign in to comment.