# Path: weechat/about/models.py
# class Screenshot(models.Model):
#     """A WeeChat screenshot."""
#     app = models.CharField(max_length=256)
#     filename = models.CharField(max_length=256)
#     comment = models.TextField(blank=True)
#     priority = models.IntegerField(default=0)
# 
#     def __str__(self):
#         return f'{self.app}: {self.filename} ({self.priority})'
# 
#     class Meta:
#         """Meta class for ScreenShot."""
#         ordering = ['priority']
# 
# class Keydate(models.Model):
#     """A WeeChat key date."""
#     date = models.DateField()
#     version = models.TextField(max_length=32)
#     text = models.TextField()
# 
#     def __str__(self):
#         str_version = f'{self.version}: ' if self.version else ''
#         return f'{self.date} - {str_version}{self.text}'
# 
#     def text_i18n(self):
#         """Return translated key date."""
#         return gettext(self.text.replace('\r\n', '\n'))
# 
#     class Meta:
#         """Meta class for KeyDate."""
#         ordering = ['-date']
# 
# class Sponsor(models.Model):
#     """A WeeChat sponsor."""
#     sponsortype = models.IntegerField(choices=SPONSOR_TYPE_CHOICES, default=0)
#     name = models.CharField(max_length=64)
#     date = models.DateField()
#     site = models.CharField(max_length=512, blank=True)
#     amount = models.DecimalField(max_digits=10, decimal_places=2)
#     number = models.IntegerField(default=1)
#     comment = models.CharField(max_length=1024, blank=True)
# 
#     def __str__(self):
#         str_num = f' (#{self.number})' if self.number > 1 else ''
#         return (f'{self.name}{str_num}, {self.sponsortype_i18n()}, '
#                 f'{self.date}, {self.amount:.2f} €')
# 
#     def date_l10n(self):
#         """Return the sponsor date formatted with localized date format."""
#         return localdate(self.date)
# 
#     def sponsortype_i18n(self):
#         """Return the translated sponsor type."""
#         return gettext(dict(SPONSOR_TYPE_CHOICES)[self.sponsortype])
# 
#     def sponsortype_svg(self):
#         """Return the name of SVG for the sponsor type."""
#         return SPONSOR_TYPE_SVG[self.sponsortype]
# 
# SPONSOR_TYPE_CHOICES = (
#     (0,
#      # Translators: context: Individual / Association / Company
#      gettext_lazy('Individual')),
#     (1,
#      # Translators: context: Individual / Association / Company
#      gettext_lazy('Association')),
#     (2,
#      # Translators: context: Individual / Association / Company
#      gettext_lazy('Company')),
# )
# 
# SPONSOR_TYPE_SVG = {
#     0: 'person',
#     1: 'persons',
#     2: 'briefcase',
# }
# 
# Path: weechat/common/path.py
# def media_path_join(*args):
#     """Join multiple paths after settings.MEDIA_ROOT."""
#     return __path_join(settings.MEDIA_ROOT, *args)
# 
# 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']


import os
from sys import version as python_version
from django import __version__ as django_version
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Sum
from django.shortcuts import render
from django.utils.translation import gettext
from weechat.about.models import (
    Screenshot,
    Keydate,
    Sponsor,
    SPONSOR_TYPE_CHOICES,
    SPONSOR_TYPE_SVG,
)
from weechat.common.path import media_path_join
from weechat.download.models import Release
            'extra_info': {
                'django': django_version,
                'python': python_version,
            },
        })
    return render(request, 'about/weechat.org.html', context)


def donate(request, sort_key='date', view_key=''):
    """Page with link for donation and list of sponsors."""
    sort_key_top = 'top10'
    sort_key_top_count = 10
    sort_count = 0
    if sort_key.startswith('top'):
        sort_key_top = sort_key
        sort_count = max(int(sort_key[3:]), 1)
        sort_key_top_count = sort_count
        sort_key = 'top'

    if sort_key == 'type':
        sponsor_list = (Sponsor.objects.values('sponsortype')
                        .annotate(amount=Sum('amount'))
                        .order_by('-amount'))
        total = sum(sponsor['amount'] for sponsor in sponsor_list)
        for sponsor in sponsor_list:
            sponsor['sponsortype_i18n'] = gettext(
                dict(SPONSOR_TYPE_CHOICES)[sponsor['sponsortype']])
            sponsor['sponsortype_svg'] = \
                SPONSOR_TYPE_SVG[sponsor['sponsortype']]
    elif sort_key == 'top':

# Path: weechat/about/models.py
# class Screenshot(models.Model):
#     """A WeeChat screenshot."""
#     app = models.CharField(max_length=256)
#     filename = models.CharField(max_length=256)
#     comment = models.TextField(blank=True)
#     priority = models.IntegerField(default=0)
# 
#     def __str__(self):
#         return f'{self.app}: {self.filename} ({self.priority})'
# 
#     class Meta:
#         """Meta class for ScreenShot."""
#         ordering = ['priority']
# 
# class Keydate(models.Model):
#     """A WeeChat key date."""
#     date = models.DateField()
#     version = models.TextField(max_length=32)
#     text = models.TextField()
# 
#     def __str__(self):
#         str_version = f'{self.version}: ' if self.version else ''
#         return f'{self.date} - {str_version}{self.text}'
# 
#     def text_i18n(self):
#         """Return translated key date."""
#         return gettext(self.text.replace('\r\n', '\n'))
# 
#     class Meta:
#         """Meta class for KeyDate."""
#         ordering = ['-date']
# 
# class Sponsor(models.Model):
#     """A WeeChat sponsor."""
#     sponsortype = models.IntegerField(choices=SPONSOR_TYPE_CHOICES, default=0)
#     name = models.CharField(max_length=64)
#     date = models.DateField()
#     site = models.CharField(max_length=512, blank=True)
#     amount = models.DecimalField(max_digits=10, decimal_places=2)
#     number = models.IntegerField(default=1)
#     comment = models.CharField(max_length=1024, blank=True)
# 
#     def __str__(self):
#         str_num = f' (#{self.number})' if self.number > 1 else ''
#         return (f'{self.name}{str_num}, {self.sponsortype_i18n()}, '
#                 f'{self.date}, {self.amount:.2f} €')
# 
#     def date_l10n(self):
#         """Return the sponsor date formatted with localized date format."""
#         return localdate(self.date)
# 
#     def sponsortype_i18n(self):
#         """Return the translated sponsor type."""
#         return gettext(dict(SPONSOR_TYPE_CHOICES)[self.sponsortype])
# 
#     def sponsortype_svg(self):
#         """Return the name of SVG for the sponsor type."""
#         return SPONSOR_TYPE_SVG[self.sponsortype]
# 
# SPONSOR_TYPE_CHOICES = (
#     (0,
#      # Translators: context: Individual / Association / Company
#      gettext_lazy('Individual')),
#     (1,
#      # Translators: context: Individual / Association / Company
#      gettext_lazy('Association')),
#     (2,
#      # Translators: context: Individual / Association / Company
#      gettext_lazy('Company')),
# )
# 
# SPONSOR_TYPE_SVG = {
#     0: 'person',
#     1: 'persons',
#     2: 'briefcase',
# }
# 
# Path: weechat/common/path.py
# def media_path_join(*args):
#     """Join multiple paths after settings.MEDIA_ROOT."""
#     return __path_join(settings.MEDIA_ROOT, *args)
# 
# 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/about/views.py
import os
from sys import version as python_version
from django import __version__ as django_version
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Sum
from django.shortcuts import render
from django.utils.translation import gettext
from weechat.about.models import (
    Screenshot,
    Keydate,
    Sponsor,
    SPONSOR_TYPE_CHOICES,
    SPONSOR_TYPE_SVG,
)
from weechat.common.path import media_path_join
from weechat.download.models import Release

            'extra_info': {
                'django': django_version,
                'python': python_version,
            },
        })
    return render(request, 'about/weechat.org.html', context)


def donate(request, sort_key='date', view_key=''):
    """Page with link for donation and list of sponsors."""
    sort_key_top = 'top10'
    sort_key_top_count = 10
    sort_count = 0
    if sort_key.startswith('top'):
        sort_key_top = sort_key
        sort_count = max(int(sort_key[3:]), 1)
        sort_key_top_count = sort_count
        sort_key = 'top'

    if sort_key == 'type':
        sponsor_list = (Sponsor.objects.values('sponsortype')
                        .annotate(amount=Sum('amount'))
                        .order_by('-amount'))
        total = sum(sponsor['amount'] for sponsor in sponsor_list)
        for sponsor in sponsor_list:
            sponsor['sponsortype_i18n'] = gettext(
                dict(SPONSOR_TYPE_CHOICES)[sponsor['sponsortype']])
            sponsor['sponsortype_svg'] = \
                SPONSOR_TYPE_SVG[sponsor['sponsortype']]
    elif sort_key == 'top':

        sponsor_list = (Sponsor.objects.values('sponsortype', 'name')