Beispiel #1
0
 def toHTML(self, input=None):
     self.sort()
     model = {}
     bv = BoxView(self)
     for k in bv.keys():
         model[k] = bv[k]
     model["stories"] = [
         BoxView(s)
         for s in [o for o in self.stories
                   if o.status != 'draft'][:NUM_ON_FRONTPAGE]
     ]
     return zebra.fetch(self.template, model)
Beispiel #2
0
    def act_welcome(self):
        try:
            a, u = self.fetchUserAndAccount()
        except:
            return

        self.model.update(BoxView(a))
        self.model.update(BoxView(u))
        self.model["shortname"] = u.server.shortname
        self.model["message"] = zebra.fetch("eml_welcome", self.model)
        self.model["subject"] = "Welcome to Cornerhost!"
        self.model["bcc"] = "*****@*****.**"
        print >> self, zebra.fetch("frm_mailer", self.model)
Beispiel #3
0
    def invoke(self, _clerk):
        signups = _clerk.match(Signup)

        def byDate(a, b):
            return cmp(a.TS, b.TS)

        signups.sort(byDate)
        return Model(signups=[BoxView(p) for p in signups])
Beispiel #4
0
 def studyChannel(self, channelID):
     assert channelID, "must supply valid channelID"
     chan = self.clerk.fetch(Channel, channelID)
     self.model["categories"] = [(c.ID, c.name) for c in chan.categories]
     # @TODO: will need to limit number of past stories soon.
     self.model["stories"] = [BoxView(s) for s in chan.stories]
     self.model["stories"].sort(lambda a, b: -cmp(a["posted"], b["posted"]))
     return chan
Beispiel #5
0
class SignupApp(App):
    userClass = User
    tplDir = "."

    def __init__(self, input, clerk, auth):
        raise Exception(
            "this class sucks. don't use it. see the 'signup' lib, or refactor this mess"
        )
        self.clerk = clerk
        self.auth = auth
        super(SignupApp, self).__init__(input)

    def act_(self):
        self.do("signup")

    def enter(self):
        self.errors = []

    ## signup process ##################################
    ## signup --> save

    def act_signup(self):
        if self.input.get("action") != "save":
            self.consult(BoxView(userClass()))
        print >> self.out, zebra.fetch(self.tplDir + "/frm_signup", self.model)

    def act_save(self):

        try:
            raise Exception("this should work like adminapp...ugh")
            #obj = self.clerk.upsert(self.userClass,
            #                        self.input.get("ID"),
            #                        **self.input)
        except ValueError, err:
            #@TODO: clean up the type mess on ValueError
            if type(err) == type([]):
                self.complain(err[0])
            else:
                self.complain(err.args[0])
        if self.errors:
            # complain:
            self.consult(BoxView(obj))
            self.consult(self.input)
            self.model["ID"] = obj.ID  # security measure, just in case..
            self.next = "signup"
        else:
            # now log in as that user:
            self.auth.login(obj.ID)
            self.next = "on_signup"
Beispiel #6
0
 def act_sendpass(self):
     try:
         user = self.userClass(email=self.input["email"])
     except:
         self.complain('''
             The email address, <b>%s</b>,
             wasn\'t found in our database.<br>
             You can
               <a href="user.py?action=signup">create a new account</a>,<br>
             or you can try a different email address below.
             ''' % weblib.request["email"])
         self.next = "requestpass"
     else:
         self.consult(BoxView(user))
         msg = zebra.fetch("eml_sendpass", self.model)
         zikebase.sendmail(msg)
         self.msg_sentpass()
Beispiel #7
0
 def list_channel(self):
     channels = [BoxView(c) for c in self.clerk.match(Channel)]
     self.generic_list(channels, "lst_channel")
Beispiel #8
0
 def list_comments(self):
     self.generic_list([BoxView(c) for c in self.clerk.match(Comment)],
                       "lst_comment")
Beispiel #9
0
 def list_author(self):
     authors = [BoxView(a) for a in self.clerk.match(Author)]
     self.generic_list(authors, "lst_author")
Beispiel #10
0
 def show_channel(self):
     chan = self.clerk.fetch(Channel, long(self.input["ID"]))
     model = {"errors": []}
     model.update(BoxView(chan))
     self.write(zebra.fetch("sho_channel", model))
Beispiel #11
0
 def toAtom(self):
     self.sort()
     return zebra.fetch("atom.zb", BoxView(self))
Beispiel #12
0
 def act_signup(self):
     if self.input.get("action") != "save":
         self.consult(BoxView(userClass()))
     print >> self.out, zebra.fetch(self.tplDir + "/frm_signup", self.model)
Beispiel #13
0
 def act_update(self):
     self.auth.check()
     self.consult(BoxView(self.auth.user))
     import os
     print >> self.out, zebra.fetch(self.tplDir + "/frm_update", self.model)
Beispiel #14
0
 def invoke(self, _clerk, ID):
     p = _clerk.fetch(Signup, ID=ID)
     return Model(signup=BoxView(p))
Beispiel #15
0
 def toRSS(self):
     self.sort()
     return zebra.fetch("rss", BoxView(self))
Beispiel #16
0
 def _showObject(self, obj, template):
     self.consult(BoxView(obj))
     self.consult(self.input)  # so we can pre-populate via url
     self._runZebra(template)
Beispiel #17
0
 def invoke(self, _clerk):
     return Model(servers=[
         BoxView(s) for s in _clerk.match(Server, status="active")
     ])