Ignore:
Timestamp:
14 Sep 2022, 08:14:28 (2 years ago)
Author:
Henrik Bettermann
Message:

Add MonthSource? to be used in custom packages.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py

    r16531 r17094  
    156156    DICT_NAME = 'DISABLE_PAYMENT_GROUP_DICT'
    157157
     158class MonthSource(BasicSourceFactory):
     159    """A months source delivers all months of the year.
     160    """
     161    def getValues(self):
     162        months_dict = getUtility(IKofaUtils).MONTHS_DICT
     163        return sorted(months_dict.keys())
     164
     165    def getToken(self, value):
     166        return value
     167
     168    def getTitle(self, value):
     169        months_dict = getUtility(IKofaUtils).MONTHS_DICT
     170        return months_dict[value]
     171
    158172# Define a validation method for email addresses
    159173class NotAnEmailAddress(schema.ValidationError):
     
    311325
    312326    PORTAL_LANGUAGE = Attribute("Dict of global language setting")
     327    MONTHS_DICT = Attribute("Dict of months of the year")
    313328    PREFERRED_LANGUAGES_DICT = Attribute("Dict of preferred languages")
    314329    EXAM_SUBJECTS_DICT = Attribute("Dict of examination subjects")
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py

    r17067 r17094  
    102102        }
    103103
     104    MONTHS_DICT = {
     105        1: _('January'),
     106        2: _('February'),
     107        3: _('March'),
     108        4: _('April'),
     109        5: _('May'),
     110        6: _('June'),
     111        7: _('July'),
     112        8: _('August'),
     113        9: _('September'),
     114        10: _('October'),
     115        11: _('November'),
     116        12: _('December'),
     117        }
     118
    104119    #: A function to return
    105120    @classmethod
Note: See TracChangeset for help on using the changeset viewer.