Exemple #1
0
    def clean(self):
        # Sanity checks
        if not self.division and not_none_or_empty(self.division_result):
            raise ValidationError("Division result cannot be set if no division is selected.")

        if not self.division and self.final_pos is not None:
            raise ValidationError("Final position cannot be set if no division is selected.")

        if not self.cup and not_none_or_empty(self.cup_result):
            raise ValidationError("Cup result cannot be set if no cup is selected.")

        # Make sure the division gender matches the team gender!
        if self.division is not None and (self.team.gender != self.division.gender):
            raise ValidationError(
                "{} is a {} team but {} is a {} division",
                self.team,
                self.team.get_gender_display(),
                self.division,
                self.division.get_gender_display(),
            )

        # Make sure the cup gender matches the team gender!
        if self.cup is not None and (self.team.gender != self.cup.gender):
            raise ValidationError(
                "{} is a {} team but {} is a {} cup",
                self.team,
                self.team.get_gender_display(),
                self.cup,
                self.cup.get_gender_display(),
            )
Exemple #2
0
    def address_known(self):
        """ Returns True if the address is known.

            Currently this just checks if the postcode field is
            populated.
        """
        return not_none_or_empty(self.addr_postcode)
Exemple #3
0
    def save(self, *args, **kwargs):
        """ Set a few automatic fields and then save """
        # Automatically add a split in the match report and pre-match-hype
        self.report_body = splitify(self.report_body.content)
        self.pre_match_hype = splitify(self.pre_match_hype.content)

        # Timestamp the report publish datetime when its first created
        if self.report_pub_timestamp is None and not_none_or_empty(self.report_body.content):
            self.report_pub_timestamp = datetime.now()

        super(Match, self).save(*args, **kwargs)
Exemple #4
0
 def match_title_text(self):
     """ Gets an appropriate match title regardless of the status of the match.
         Examples include:
             "Men's 1sts thrash St Neots"
             "M1 vs St Neots Men's 1sts"
             "M1 vs St Neots Men's 1sts - POSTPONED"
             "M1 vs St Neots Men's 1sts - CANCELLED"
             "M1 3-0 St Neots Men's 1sts (WALK-OVER)"
             "M1 5-1 St Neots Men's 1sts"
     """
     if not_none_or_empty(self.report_title):
         return self.report_title
     else:
         return self.fixture_title()
Exemple #5
0
 def has_report(self):
     """ Returns True if this match has a match report"""
     return self.report_body and not_none_or_empty(self.report_body.content)