# Path: weechat/download/models.py
# class Release(models.Model):
#     """A WeeChat release."""
#     version = models.CharField(max_length=64, primary_key=True)
#     description = models.CharField(max_length=64, blank=True)
#     date = models.DateField(blank=True, null=True)
#     security_issues_fixed = models.IntegerField(default=0)
#     securityfix = models.CharField(max_length=256, blank=True)
# 
#     def __str__(self):
#         security_fix = (f', {self.security_issues_fixed} SECURITY FIX'
#                         if self.security_issues_fixed > 0 else '')
#         fixed_in = (f', fix in: {", ".join(self.securityfix.split(","))}'
#                     if self.securityfix else '')
#         return f'{self.version} ({self.date}){security_fix}{fixed_in}'
# 
#     def date_l10n(self):
#         """Return the release date formatted with localized date format."""
#         return localdate(self.date)
# 
#     def security_fixed_versions(self):
#         """Return the list of versions fixing security issues."""
#         return self.securityfix.split(',')
# 
#     @property
#     def is_released(self):
#         """Return True if the version is released."""
#         stable_version = Release.objects.get(version='stable').description
#         stable_version_tuple = version_to_tuple(stable_version)
#         return version_to_tuple(self.version) <= stable_version_tuple
# 
#     class Meta:
#         ordering = ['-date']
# 
# Path: weechat/news/models.py
# class Info(models.Model):
#     """A WeeChat info."""
#     visible = models.BooleanField(default=False)
#     date = models.DateTimeField()
#     title = models.CharField(max_length=64)
#     author = models.CharField(max_length=256)
#     mail = models.EmailField(max_length=256)
#     text = models.TextField(blank=True)
# 
#     def __str__(self):
#         return f'{self.title} ({self.date})'
# 
#     def date_l10n(self):
#         """Return the info date formatted with localized date format."""
#         return localdate(self.date)
# 
#     def title_i18n(self):
#         """Return translated title."""
#         match = PATTERN_TITLE_VERSION.match(self.title)
#         if match:
#             # if the title is "Version x.y.z", translate only "Version"
#             return f'{gettext(match.group(1))} {match.group(2)}'
#         return gettext(self.title)
# 
#     def text_i18n(self):
#         """Return translated text."""
#         if self.text:
#             return gettext(self.text.replace('\r\n', '\n'))
#         return ''
# 
#     def date_title_url(self):
#         """Return date+title to include in URL."""
#         text_url = re.sub(' +', '-',
#                           re.sub('[^ a-zA-Z0-9.]', ' ', self.title).strip())
#         return (f'{self.date.year:0>4}{self.date.month:0>2}{self.date.day:0>2}'
#                 f'-{text_url}')


from datetime import datetime
from django.core.exceptions import ObjectDoesNotExist
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import render
from weechat.download.models import Release
from weechat.news.models import Info
        pagesize = 10
    infos, smart_page_range = paginate_news(request, info_list, pagesize)
    event = infos and infos[0].date > datetime.now()
    return render(request, 'home/news.html', {
        'infos': infos,
        'info_id': info_id,
        'event': event,
        'page_name': page_name,
        'smart_page_range': smart_page_range,
        'pagesize': pagesize,
    })


def news(request, info_id=None, title=None):
    """List of news."""
    # pylint: disable=unused-argument
    try:
        if info_id:
            info_list = [Info.objects.get(id=info_id, visible=1)]
        else:
            info_list = (Info.objects.all().filter(visible=1)
                         .filter(date__lte=datetime.now()).order_by('-date'))
    except ObjectDoesNotExist:
        info_list = []
    return render_news(request, info_list, info_id, 'news')


def events(request):
    """List of upcoming events."""
    try:

# Path: weechat/download/models.py
# class Release(models.Model):
#     """A WeeChat release."""
#     version = models.CharField(max_length=64, primary_key=True)
#     description = models.CharField(max_length=64, blank=True)
#     date = models.DateField(blank=True, null=True)
#     security_issues_fixed = models.IntegerField(default=0)
#     securityfix = models.CharField(max_length=256, blank=True)
# 
#     def __str__(self):
#         security_fix = (f', {self.security_issues_fixed} SECURITY FIX'
#                         if self.security_issues_fixed > 0 else '')
#         fixed_in = (f', fix in: {", ".join(self.securityfix.split(","))}'
#                     if self.securityfix else '')
#         return f'{self.version} ({self.date}){security_fix}{fixed_in}'
# 
#     def date_l10n(self):
#         """Return the release date formatted with localized date format."""
#         return localdate(self.date)
# 
#     def security_fixed_versions(self):
#         """Return the list of versions fixing security issues."""
#         return self.securityfix.split(',')
# 
#     @property
#     def is_released(self):
#         """Return True if the version is released."""
#         stable_version = Release.objects.get(version='stable').description
#         stable_version_tuple = version_to_tuple(stable_version)
#         return version_to_tuple(self.version) <= stable_version_tuple
# 
#     class Meta:
#         ordering = ['-date']
# 
# Path: weechat/news/models.py
# class Info(models.Model):
#     """A WeeChat info."""
#     visible = models.BooleanField(default=False)
#     date = models.DateTimeField()
#     title = models.CharField(max_length=64)
#     author = models.CharField(max_length=256)
#     mail = models.EmailField(max_length=256)
#     text = models.TextField(blank=True)
# 
#     def __str__(self):
#         return f'{self.title} ({self.date})'
# 
#     def date_l10n(self):
#         """Return the info date formatted with localized date format."""
#         return localdate(self.date)
# 
#     def title_i18n(self):
#         """Return translated title."""
#         match = PATTERN_TITLE_VERSION.match(self.title)
#         if match:
#             # if the title is "Version x.y.z", translate only "Version"
#             return f'{gettext(match.group(1))} {match.group(2)}'
#         return gettext(self.title)
# 
#     def text_i18n(self):
#         """Return translated text."""
#         if self.text:
#             return gettext(self.text.replace('\r\n', '\n'))
#         return ''
# 
#     def date_title_url(self):
#         """Return date+title to include in URL."""
#         text_url = re.sub(' +', '-',
#                           re.sub('[^ a-zA-Z0-9.]', ' ', self.title).strip())
#         return (f'{self.date.year:0>4}{self.date.month:0>2}{self.date.day:0>2}'
#                 f'-{text_url}')


# Path: weechat/news/views.py
from datetime import datetime
from django.core.exceptions import ObjectDoesNotExist
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import render
from weechat.download.models import Release
from weechat.news.models import Info

        pagesize = 10
    infos, smart_page_range = paginate_news(request, info_list, pagesize)
    event = infos and infos[0].date > datetime.now()
    return render(request, 'home/news.html', {
        'infos': infos,
        'info_id': info_id,
        'event': event,
        'page_name': page_name,
        'smart_page_range': smart_page_range,
        'pagesize': pagesize,
    })


def news(request, info_id=None, title=None):
    """List of news."""
    # pylint: disable=unused-argument
    try:
        if info_id:
            info_list = [Info.objects.get(id=info_id, visible=1)]
        else:
            info_list = (Info.objects.all().filter(visible=1)
                         .filter(date__lte=datetime.now()).order_by('-date'))
    except ObjectDoesNotExist:
        info_list = []
    return render_news(request, info_list, info_id, 'news')


def events(request):
    """List of upcoming events."""
    try:

        info_list = (Info.objects.all().filter(visible=1)