1# -*- coding: utf-8 -*- 2# 3# Copyright (C) 2016-2021 by the Free Software Foundation, Inc. 4# 5# This file is part of Django-Mailman. 6# 7# Django-Mailman is free software: you can redistribute it and/or modify it 8# under the terms of the GNU General Public License as published by the Free 9# Software Foundation, either version 3 of the License, or (at your option) 10# any later version. 11# 12# Django-Mailman is distributed in the hope that it will be useful, but WITHOUT 13# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15# more details. 16# 17# You should have received a copy of the GNU General Public License along with 18# Django-Mailman. If not, see <http://www.gnu.org/licenses/>. 19# 20# Author: Aurelien Bompard <abompard@fedoraproject.org> 21# 22 23 24from django.conf import settings 25from django.contrib.sites.models import Site 26from django.db import models 27 28import pytz 29 30 31#: A list of common timezones as options for a user to choose their own. 32TIMEZONES = sorted([(tz, tz) for tz in pytz.common_timezones]) 33 34 35class Profile(models.Model): 36 user = models.OneToOneField(settings.AUTH_USER_MODEL, 37 related_name="mailman_profile", 38 on_delete=models.CASCADE) 39 timezone = models.CharField(max_length=100, choices=TIMEZONES, default="") 40 41 def __str__(self): 42 return '<Mailman profile for %s>' % self.user.username 43 44 45class MailDomain(models.Model): 46 site = models.ForeignKey(Site, related_name="mailman_domains", 47 on_delete=models.CASCADE) 48 mail_domain = models.CharField(max_length=255, db_index=True, unique=True) 49 50 def __str__(self): 51 return '<Mailman domain %s>' % self.mail_domain 52