Ejemplo n.º 1
0
    def printBody(self):
        '''
                Prints all agents in a table if anything is found similar to the
                search term.
                '''
        print "<h1>"
        print self.title
        print "</h1><table class = 'memberlist'>"
        register = PersonReg("database.db")
        agent_id_list = register.search(self.searchTerm)
        for agent_id in agent_id_list:
            agent = register.getAgent(agent_id)
            print "<tr>"
            print "<td>"
            print "<a href='agent_info.cgi?agentid=%d'>" % agent.getId()
            print agent.getName()
            print "</a>"
            print "</td><td>"
            print "<a href='agent_info.cgi?agentid=%d'>" % agent.getId()
            print agent.getLastname()
            print "</a>"
            print "</td><td>"
            print "<a href='agent_info.cgi?agentid=%d'>" % agent.getId()
            print agent.getEmail()
            print "</a>"
            print "</td></tr>"
        print "</table>"

        print """<form class = 'BackButtonMemberList' action = 'index.cgi'
Ejemplo n.º 2
0
 def setNote(self, note_id):
         '''
         str -> (title, note, note_id)
         Uses note id to get a note object, created by PersonReg after
         cursor gets information from the database.
         '''
         self.db = PersonReg("database.db")
         self.note = self.db.getNote(note_id)
Ejemplo n.º 3
0
class EditNote(WebPage):

        def printBody(self):
                '''
                Page that lets edit old notes. All data are fetched from the database and
                displayed in the fields, ready to be edited
                '''
                print "<div class = 'AgentInfo'>"
                print "<h2> %s, %s </h2>" % (self.agent.getName(), self.agent.getLastname())
                print "<p>Email: %s </p>" % (self.agent.getEmail())
                print "</div>"
                print "<form action='saveChanges.cgi?note_id=%d&agent_id=%s' method='post'>" % (self.note[2], self.agent.getId())
                print "<input class='notetitle' type = 'text' value = '%s' name = 'note_title'>" % self.note[0]
                print "<textarea rows='15' cols='120' class='notetext' name = 'note_text'>%s</textarea>" % self.note[1]
                print "<input type='hidden' name ='button' value='3'>"
                print "<input class='notebutton' type='submit' value='Save Changes'> </form>"

                print "<form class = 'DeleteNotes' action = 'saveChanges.cgi?note_id=%d&agent_id=%s' method = 'post'>" % (self.note[2], self.agent.getId())
                print "<input type = 'hidden' name = 'button' value = '4'>"
                print "<input type = 'submit' value = 'Delete Note'> </form>"

                #Back button code from http://www.computerhope.com/issues/ch000317.htm
                print """<form class = ' BackButtonMemberList'><input type="button"
                value="Back" onClick="history.go(-1);return true;"></form>"""

        def setNote(self, note_id):
                '''
                str -> (title, note, note_id)
                Uses note id to get a note object, created by PersonReg after
                cursor gets information from the database.
                '''
                self.db = PersonReg("database.db")
                self.note = self.db.getNote(note_id)

        def setAgent(self, agent_id):
                '''Fetches info from SQL database using PersonReg and returns
                agent object.'''
                self.registry = PersonReg("database.db")
                self.agent = self.registry.getAgent(agent_id)
Ejemplo n.º 4
0
    def printBody(self):
        print """<form class = "delAgent" action="deleteAgent.cgi"
                method = "post" id = "checkvals"> <input type="submit" value="Delete">
                </form>"""

        print """<table class = "memberlist" >"""
        register = PersonReg("database.db")
        agentlist = register.search("")
        for agent_id in agentlist:
            agent = register.getAgent(agent_id)
            print "<tr><td>"
            print '<input type= "checkbox" name="checkid" form = "checkvals" value = %d>' % agent.getId(
            )
            print "</td><td>"
            print "<a href='agent_info.cgi?agentid=%d'>" % agent.getId()
            print agent.getName().encode("Latin-1")
            print "</a>"
            print "</td><td>"
            print "<a href='agent_info.cgi?agentid=%d'>" % agent.getId()
            print agent.getLastname()
            print "</a>"
            print "</td><td>"
            print "<a href='agent_info.cgi?agentid=%d'>" % agent.getId()
            print agent.getEmail()
            print "</a>"
            print "</td></tr>"
        print "</table>"
        print "<br>"

        print
        print "<form class = 'addAgent' action='addAgent.cgi' method='post'>"
        print "<h2 class= 'NewMemb'>Add new member:</h2>"
        print("<label>First name: </label> <input type='text' name='fname'>")
        print("<label>Last name:</label> <input type='text' name='lname'>")
        print("<label>Email adress:</label><input type='text' name='mail'>")
        print "<br> </br> <br> </br>"
        print("<label>Title:</label> <input type='text' name='note_title'>")
Ejemplo n.º 5
0
class EditAgent(WebPage):
        '''A simple page that displays all information known about a person in
        editable text fields each for name, lastname and email address.
        A delete and Save Changes button is also present.'''
        def printBody(self):
                print "<form class = 'delAgent' action='deleteAgent.cgi?id=%s' method='post'>" % self.agent.getId()
                print "<input type='submit' value='Delete %s %s'>" % (self.agent.getName(), self.agent.getLastname())
                print "<input type='hidden' value='2' name = 'button'> </form>"

                print "<form class = 'addAgent' action='saveChanges.cgi?id=%s' method = 'post'>" % self.agent.getId()
                print "First name: <input type='text' name='fname' value='%s'>" % self.agent.getName()
                print "Last name: <input type='text' name='lname' value='%s'>" % self.agent.getLastname()
                print "Email: <input type='text' name='mail' value='%s'> <br> </br> <br> </br>" % self.agent.getEmail()
                print "<input type='hidden' name = 'button' value='0'>"
                print "<input type='submit' value='Save Changes'> </form>"

                print """<form class = 'BackButtonMemberList' action = 'agent_info.cgi'
                method = 'get'> <input type = 'submit' value = 'Back'>
                <input type = 'hidden' name = 'agentid' value = '%s'> </form>""" % self.agent.getId()


        def setAgent(self, agent_id):
                self.registry = PersonReg("database.db")
                self.agent = self.registry.getAgent(agent_id)
Ejemplo n.º 6
0
 def setAgent(self, agent_id):
         '''Fetches info from SQL database using PersonReg and returns
         agent object.'''
         self.registry = PersonReg("database.db")
         self.agent = self.registry.getAgent(agent_id)
Ejemplo n.º 7
0
 def setAgent(self, agent_id):
         self.registry = PersonReg("database.db")
         self.agent = self.registry.getAgent(agent_id)