Ejemplo n.º 1
0
 def testGetHeaderMessagesFullContacts(self):
     result = FullContacts("").getHeaderMessages()
     expectedResult = """
     <p>
         <a href="http://www.gsam.co.uk/" target="_blank">Game Set &amp; Match</a>, the
         League's sponsors, are located at Unit 1, Beaver Trade Park, Quarry Lane, Chichester PO19 8NY
         (tel: 01243 538800).
     </p>
     <p>
         The main means of communication on league matters is by e-mail. <b>For
         urgent contacts, however, it may be preferable to telephone; telephone
         numbers for committee members, club secretaries and team captains and
         managers are given below.</b>
     </p>
     <p>
         All e-mail contacts should be made using the e-mail addresses
         assigned to the relevant roles in the League's domain (that is,
         addresses ending with <i>sehicl.org.uk</i>). This ensures that when the
         person performing a role changes, the e-mail is still routed to the correct
         person. The easiest way to do this is to click on the person's name in
         the lists below.
     </p>
     <p>
         Please let <script language="javascript">
             document.write(mailTo("website", "", "SEHICL Webmaster", "the Webmaster"));
         </script>
         <noscript>the Webmaster<i> (Javascript not enabled: cannot display mail link)</i>
         </noscript> know if any of the information below is incomplete or incorrect.
     </p>
     """
     self.assertMultiLineEqual(expectedResult, result)
Ejemplo n.º 2
0
 def testGetClubContactsHtml(self):
     contactsByRole = {}
     contactsByRole["Secretary"] = [(PersonData(name="Contact 1",
                                                address="Buckingham Palace",
                                                phoneNumbers=["0124124"]),
                                     RoleData(email="thesecretary"))]
     contactsByRole["Under-16"] = [(PersonData(name="Contact 2",
                                               phoneNumbers=["113"]),
                                    RoleData())]
     contactsByRole["Captain"] = [(PersonData(name="Contact 3",
                                              phoneNumbers=["999"]),
                                   RoleData())]
     result = FullContacts("").getClubContactsHtml("My Club",
                                                   contactsByRole)
     expectedResult = """
     <tr>
     <td class="role">My Club</td>
     <td>
     Secretary: <script language="javascript">
         document.write(mailTo("thesecretary", "", "", "Contact 1"));
     </script>
     <noscript>Contact 1<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript><br>
     Buckingham Palace<br>
     0124124<br>
     Captain: Contact 3, 
     999<br>
     Under-16: Contact 2, 
     113
     </td>
     </tr>
     """
     self.assertMultiLineEqual(expectedResult, result)
Ejemplo n.º 3
0
 def testGetPersonHtmlPersonSpecifiedEmailNotSpecifiedFullNoAddressNoPhoneNumbers(
         self):
     person = PersonData(name="Pandolf Ironhead")
     email = None
     defaultText = "Hello goodbye"
     result = FullContacts("").getPersonHtml(person, email, defaultText,
                                             True)
     expectedResult = "Pandolf Ironhead"
     self.assertEquals(expectedResult, result)
Ejemplo n.º 4
0
 def testGetPersonHtmlPersonSpecifiedEmailNotSpecifiedFullNoAddressMultiplePhoneNumbers(
         self):
     person = PersonData(name="Pandolf Ironhead",
                         phoneNumbers=["01329312895", "07878727131"])
     email = None
     defaultText = "Hello goodbye"
     result = FullContacts("").getPersonHtml(person, email, defaultText,
                                             True)
     expectedResult = """
     Pandolf Ironhead, 
     01329312895 / 07878727131
     """
     self.assertMultiLineEqual(expectedResult, result)
Ejemplo n.º 5
0
 def testGetPersonHtmlPersonSpecifiedEmailNotSpecifiedFullAddressNoPhoneNumbers(
         self):
     person = PersonData(name="Pandolf Ironhead",
                         address="Schloss Eisenkopf")
     email = None
     defaultText = "Hello goodbye"
     result = FullContacts("").getPersonHtml(person, email, defaultText,
                                             True)
     expectedResult = """
     Pandolf Ironhead<br>
     Schloss Eisenkopf
     """
     self.assertMultiLineEqual(expectedResult, result)
Ejemplo n.º 6
0
 def testGetPersonHtmlPersonSpecifiedEmailSpecifiedFullNoAddressNoPhoneNumbers(
         self):
     person = PersonData(name="Pandolf Ironhead")
     email = "pandolf"
     defaultText = "Hello goodbye"
     result = FullContacts("").getPersonHtml(person, email, defaultText,
                                             True)
     expectedResult = """
     <script language="javascript">
         document.write(mailTo("pandolf", "", "", "Pandolf Ironhead"));
     </script>
     <noscript>Pandolf Ironhead<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript>
     """
     self.assertMultiLineEqual(expectedResult, result)
Ejemplo n.º 7
0
 def testGetPersonHtmlPersonSpecifiedEmailSpecifiedFullAddressMultiplePhoneNumbers(
         self):
     person = PersonData(name="Pandolf Ironhead",
                         address="Schloss Eisenkopf",
                         phoneNumbers=["01329312895", "07878727131"])
     email = "pandolf"
     defaultText = "Hello goodbye"
     result = FullContacts("").getPersonHtml(person, email, defaultText,
                                             True)
     expectedResult = """
     <script language="javascript">
         document.write(mailTo("pandolf", "", "", "Pandolf Ironhead"));
     </script>
     <noscript>Pandolf Ironhead<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript><br>
     Schloss Eisenkopf<br>
     01329312895 / 07878727131
     """
     self.assertMultiLineEqual(expectedResult, result)
Ejemplo n.º 8
0
    def testGetContactData(self):
        xml = """
        <contacts>
            <person>
                <name>Barry Plumb</name>
                <address>Pine Corner, 7A Anthill Close, Denmead PO7 6ND</address>
                <phone>07738 005543</phone>
                <role name="Treasurer">
                    <email id="treasurer" />
                </role>
            </person>

            <person>
                <name>Matt Reeves</name>
                <phone>07807 045580</phone>
                <role name="A team" club="Sarisbury Athletic" />
            </person>

            <person>
                <name>Andy Reynolds</name>
                <phone>07748 844609</phone>
                <role name="Under-13" club="Waterlooville" />
            </person>

            <person>
                <name>Steve Roberts</name>
                <address>192a Locks Road, Locks Heath SO31 6LE</address>
                <phone>01489 581477</phone>
                <phone>07918 671878</phone>
                <role name="Secretary" club="Sarisbury Athletic">
                    <email id="sarisbury.secretary" />
                </role>
            </person>
        </contacts>
        """
        rootElement = ElementTree.fromstring(xml)
        result = FullContacts("").getContactData(rootElement)
        expectedNames = [
            "Barry Plumb", "Matt Reeves", "Andy Reynolds", "Steve Roberts"
        ]
        for e, a in zip(expectedNames, result):
            self.assertEquals(e, a.name)
        self.assertEquals(len(expectedNames), len(result))
Ejemplo n.º 9
0
 def testGetPersonDataFullData(self):
     xml = """
     <person>
         <name>Rick Marston</name>
         <address>113 Festing Grove, Portsmouth PO4 9QE</address>
         <phone>023 9273 5987</phone>
         <phone>07724 138531</phone>
         <role name="Secretary" club="Portsmouth">
             <email id="portsmouth.secretary" />
         </role>
         <role name="B team" club="Portsmouth" />
         <role name="C team" club="Portsmouth" />
         <role name="Under-16" club="Portsmouth" />
     </person>
     """
     personElement = ElementTree.fromstring(xml)
     result = FullContacts("").getPersonData(personElement)
     self.assertEquals("Rick Marston", result.name)
     self.assertEquals(4, len(result.roles))
     self.assertEquals("113 Festing Grove, Portsmouth PO4 9QE",
                       result.address)
     self.assertEquals(["023 9273 5987", "07724 138531"],
                       result.phoneNumbers)
Ejemplo n.º 10
0
 def testGetContentFullContacts(self):
     rootElement = ElementTree.parse("testData/contacts.xml")
     FullContacts("").getContent(rootElement)
Ejemplo n.º 11
0
class PageList:
    '''
    classdocs
    '''

    defaultPage = "home"

    pageList = []
    pageList.append(HomePage("home"))
    pageList.append(
        StaticPage("notfound",
                   "{0}/notfound.html".format(Settings.staticHtmlDirectory),
                   "Page not found!"))
    pageList.append(UserAdmin("userAdmin", role="admin"))
    pageList.append(PartialContacts("contacts"))
    pageList.append(FullContacts("fullContacts", role=""))
    pageList.append(
        StaticPage(
            "presentation", "{0}/PresentationEvening.html".format(
                Settings.staticHtmlDirectory), "SEHICL Presentation Evening"))
    pageList.append(TeamFixtures("teamFixtures"))
    pageList.append(LeagueFixtures("allFixtures"))
    pageList.append(LeagueFixtures("leagueFixtures"))
    pageList.append(LeagueResults("leagueResults"))
    pageList.append(DateResults("latestResults"))
    pageList.append(DateResults("dateResults"))
    pageList.append(LeagueTable("tables"))
    pageList.append(LeagueTable("leagueTable"))
    pageList.append(AveragesIndex("averagesIndex"))
    pageList.append(BattingAverages("battingAverages"))
    pageList.append(BowlingAverages("bowlingAverages"))
    pageList.append(BattingAverages("leagueBattingAverages"))
    pageList.append(BowlingAverages("leagueBowlingAverages"))
    pageList.append(TeamAverages("teamAverages"))
    pageList.append(TeamAveragesIndex("teamAveragesIndex"))
    pageList.append(
        StaticPage("rules",
                   "{0}/rules.html".format(Settings.staticHtmlDirectory),
                   "SEHICL Rules and Playing Conditions"))
    pageList.append(DutyRota("fixturesDutyRota"))
    pageList.append(
        StaticPage("resources",
                   "{0}/resources.html".format(Settings.staticHtmlDirectory),
                   "SEHICL Resources"))
    pageList.append(
        RecordsIndex(
            "records", "{0}/records/recordsindex.html".format(
                Settings.staticHtmlDirectory)))
    pageList.append(
        StaticPage(
            "recordsPerformances",
            "{0}/records/recordperformances.html".format(
                Settings.staticHtmlDirectory),
            "SEHICL Records: Record Performances"))
    pageList.append(
        StaticPage(
            "recordsWinners",
            "{0}/records/divwinners.html".format(Settings.staticHtmlDirectory),
            "SEHICL Honours Board: Divisional Winners"))
    pageList.append(
        StaticPage(
            "recordsAwards", "{0}/records/individualawards.html".format(
                Settings.staticHtmlDirectory),
            "SEHICL Honours Board: Individual Awards"))
    pageList.append(
        StaticPage(
            "recordsFairplay",
            "{0}/records/fairplay.html".format(Settings.staticHtmlDirectory),
            "SEHICL Honours Board: Sporting and Efficiency"))
    lastArchiveSeason = 15
    pageList.append(ArchiveIndex("archive", lastArchiveSeason))
    additionalPromotions = {}
    additionalPromotions[6] = {"Division3": [3], "Division4": [3]}
    additionalPromotions[7] = {"Division3": [3, 4], "Division4": [3, 4]}
    additionalPromotions[10] = {"Division4": [4]}
    additionalPromotions[12] = {"Division4": [3, 4]}
    additionalPromotions[13] = {"Division3": [3], "Division4": [3]}
    additionalPromotions[14] = {
        "Division2": [3],
        "Division3": [3],
        "Division4": [3, 4]
    }
    additionalPromotions[15] = {"Division4": [3]}
    for s in range(4, lastArchiveSeason + 1):
        index = ArchiveSeasonIndex("archive{0}".format(s))
        title = index.getTitle()
        pageList.append(index)
        for divName in ("Division 1", "Division 2", "Division 3", "Division 4",
                        "Colts Under-16", "Colts Under-13"):
            divId = re.sub("[ -]", "", divName)
            pageId = "archive{0}{1}Table".format(s, divId)
            if s < 6:
                pageFile = "{2}/archive{0}/{1}.html".format(
                    s, divId, Settings.staticHtmlDirectory)
                pageList.append(StaticPage(pageId, pageFile, title))
            else:
                params = {"season": s, "league": divId, "archive": "yes"}
                ap = additionalPromotions.get(s, {}).get(divId, None)
                if ap is not None:
                    params["additionalPromotions"] = ap
                pageList.append(LeagueTable(pageId, params))
        for section in ("Senior", "Colts Under-16", "Colts Under-13"):
            for activity in ("Batting", "Bowling"):
                sectionId = re.sub("[ -]", "", section)
                pageId = "archive{0}{1}{2}".format(s, sectionId, activity)
                if s < 6:
                    pageFile = "{3}/archive{0}/{1}{2}.html".format(
                        s, sectionId, activity, Settings.staticHtmlDirectory)
                    pageList.append(StaticPage(pageId, pageFile, title))
                else:
                    parms = {"season": s, "archive": "yes"}
                    if (sectionId != "Senior"):
                        parms["league"] = sectionId
                    if activity == "Batting":
                        pageList.append(BattingAverages(pageId, parms))
                    else:
                        pageList.append(BowlingAverages(pageId, parms))
        if index.presentation:
            pageId = "archive{0}Presentation".format(s)
            pageFile = "{0}/archive{1}/PresentationEvening.html".format(
                Settings.staticHtmlDirectory, s)
            pageList.append(StaticPage(pageId, pageFile, title))
    pageList.append(UserRegistration("register"))
    pageList.append(UserActivation("activate"))
    pageList.append(UserLogin("login"))

    pages = {}
    for p in pageList:
        pages[p.pageId] = p