def rend(self, *junk):
        prefixURL = '/' + self.imageSet.store.findUnique(
            ThumbnailDisplayer).prefixURL + '/'
        toWebID = ixmantissa.IWebTranslator(self.imageSet.store).toWebID

        return (tags.img(src=prefixURL + toWebID(img),
                         width='20%',
                         height='20%') for img in self.imageSet.getImages())
    def rend(self, ctx, data):
        translator = ixmantissa.IWebTranslator(self.original.part.store)
        webid = translator.toWebID(self.original.part)

        messageURL = translator.linkTo(self.original.part.message.storeID)

        return self.iframePattern.fillSlots(
            'location',  # argh
            messageURL + '/attachments/' + webid)
    def __init__(self, original):
        athena.LiveFragment.__init__(self, original)
        self.organizer = original.store.findUnique(people.Organizer)
        self.translator = ixmantissa.IWebTranslator(original.store)

        self.tdm = tdb.TabularDataModel(original.store,
                                        Image, (Image.message, ),
                                        baseComparison=self._getComparison(),
                                        defaultSortColumn='message',
                                        itemsPerPage=self.itemsPerRow *
                                        self.rowsPerPage)
    def __init__(self, original):
        self.original = original
        # think about this some more - the messageID or partID could be the
        # mangled storeID of the part to facilitate the making of child
        # links here, but nobody except for us really needs to know about
        # this.
        self.docFactory = getLoader('message-detail-patterns')
        self.iframePattern = inevow.IQ(
            self.docFactory).patternGenerator('content-iframe')

        self.urlPrefix = ixmantissa.IWebTranslator(original.part.store).linkTo(
            original.messageID)
 def blogs(self, req, tag):
     """
     Render all blogs
     """
     p = inevow.IQ(self.docFactory).patternGenerator('blog')
     webapp = ixmantissa.IWebTranslator(self.hyperbola.store)
     blogs = list()
     primaryRole = sharing.getSelfRole(self.hyperbola.store)
     for blog in self.hyperbola.getTopLevelFor(primaryRole):
         blogs.append(p.fillSlots(
                 'title', blog.title).fillSlots(
                 'link', websharing.linkTo(blog)).fillSlots(
                 'post-url', self._getPostURL(blog)))
     return tag[blogs]
Beispiel #6
0
    def __init__(self, inbox):
        athena.LiveElement.__init__(self)
        self.translator = ixmantissa.IWebTranslator(inbox.store)
        self.store = inbox.store
        self.inbox = inbox

        self.viewSelection = {
            "view": "inbox",
            "tag": None,
            "person": None,
            "account": None}

        self.scrollingFragment = self._createScrollingFragment()
        self.scrollingFragment.setFragmentParent(self)
Beispiel #7
0
 def __init__(self, store):
     Scrollable.__init__(self, ixmantissa.IWebTranslator(store, None),
                         columns=(Message.sender,
                                  Message.senderDisplay,
                                  Message.recipient,
                                  Message.subject,
                                  Message.receivedWhen,
                                  Message.read,
                                  Message.sentWhen,
                                  Message.attachments,
                                  Message.everDeferred),
                         defaultSortColumn=Message.receivedWhen,
                         defaultSortAscending=False)
     LiveElement.__init__(self)
     self.store = store
     self.setViewSelection({u"view": "inbox", u"tag": None, u"person": None, u"account": None})
Beispiel #8
0
 def test_redirectToSettingsWhenLoggedIn(self):
     """
     When a user is already logged in, navigating to /resetPassword should
     redirect to the settings page, since the user can change their password
     from there.
     """
     self.assertNotIdentical(self.userStore.parent, None) # sanity check
     prefPage = ixmantissa.IPreferenceAggregator(self.userStore)
     urlPath = ixmantissa.IWebTranslator(self.userStore).linkTo(prefPage.storeID)
     request = FakeRequest(headers={"host": "example.com"})
     app = IResource(self.userStore)
     rsc = IResource(app.locateChild(request, ("resetPassword",))[0])
     d = renderPage(rsc, reqFactory=lambda : request)
     def rendered(result):
         self.assertEquals(
             'http://example.com' + urlPath,
             request.redirected_to)
     d.addCallback(rendered)
     return d
Beispiel #9
0
    def __init__(self, composer, message):
        """
        @type composer: L{Composer}

        @param message: the message being redirected
        @type message: L{Message}
        """
        self.composer = composer
        self.message = message

        self.translator = ixmantissa.IWebTranslator(composer.store)

        super(RedirectingComposeFragment, self).__init__(
            callable=self.redirect,
            parameters=(liveform.Parameter(name='fromAddress',
                                           type=liveform.TEXT_INPUT,
                                           coercer=self.translator.fromWebID),
                        liveform.Parameter(name='toAddresses',
                                           type=liveform.TEXT_INPUT,
                                           coercer=self._coerceEmailAddressString)))
 def view(self, request, tag):
     """
     Render the child blurbs of this blurb
     """
     blurbs = self._getChildBlurbs(request)
     if 0 < len(blurbs):
         blurbItem = sharing.itemFromProxy(self.original)
         fragment = ShareScrollingElement(
             self.getRole(),
             blurbItem.store,
             Blurb,
             Blurb.parent == blurbItem,
             [_BlurbTimestampColumn(), BlurbViewColumn()],
             Blurb.dateCreated, False,
             ixmantissa.IWebTranslator(blurbItem.store))
         _docFactorify(fragment)
         fragment.setFragmentParent(self)
         return fragment
     else:
         p = inevow.IQ(tag).onePattern('no-child-blurbs')
         return p.fillSlots('child-type-name', self._childTypeName)
Beispiel #11
0
def _viewSelectionToMailboxSelector(store, viewSelection):
    """
    Convert a 'view selection' object, sent from the client, into a MailboxSelector
    object which will be used to view the mailbox.

    @param store: an L{axiom.store.Store} that contains some messages.

    @param viewSelection: a dictionary with 4 keys: 'view', 'tag', 'person',
    'account'.  This dictionary represents the selections that users have
    made in the 4-section 'complexity 3' filtering UI.  Each key may have a
    string value, or None.  If the value is None, the user has selected
    'All' for that key in the UI; if the value is a string, the user has
    selected that string.

    @return: a L{MailboxSelector} object.
    """
    view, tag, personWebID, account = map(
        viewSelection.__getitem__,
        [u"view", u"tag", u"person", u"account"])

    sq = MailboxSelector(store)
    sq.setLimit(None)
    if view in TOUCH_ONCE_VIEWS:
        sq.setOldestFirst()
    else:
        sq.setNewestFirst()
    if view == u'all':
        view = CLEAN_STATUS

    sq.refineByStatus(view) # 'view' is really a status!  and the names
                            # even line up!
    if tag is not None:
        sq.refineByTag(tag)
    if account is not None:
        sq.refineBySource(account)
    if personWebID is not None:
        person = ixmantissa.IWebTranslator(store).fromWebID(personWebID)
        sq.refineByPerson(person)
    return sq
Beispiel #12
0
    def render_messages(self, *junk):
        iq = inevow.IQ(self.docFactory)
        msgpatt = iq.patternGenerator('message')
        newpatt = iq.patternGenerator('unread-message')
        content = []
        addresses = set(self.person.store.query(
                            people.EmailAddress,
                            people.EmailAddress.person == self.person).getColumn('address'))

        wt = ixmantissa.IWebTranslator(self.person.store)
        link = lambda href, text: tags.a(href=href, style='display: block')[text]

        displayName = self.person.getDisplayName()
        for m in self.messageLister.mostRecentMessages(self.person):
            if m.sender in addresses:
                sender = displayName
            else:
                sender = 'Me'
            if m.read:
                patt = msgpatt
            else:
                patt = newpatt
            if not m.subject or m.subject.isspace():
                subject = '<no subject>'
            else:
                subject = m.subject

            url = wt.linkTo(m.storeID)
            content.append(dictFillSlots(patt,
                                         dict(sender=link(url, sender),
                                              subject=link(url, subject),
                                              date=link(url, m.receivedWhen.asHumanly()))))

        if 0 < len(content):
            return iq.onePattern('messages').fillSlots('messages', content)
        return iq.onePattern('no-messages')
Beispiel #13
0
 def __init__(self, original):
     self.translator = ixmantissa.IWebTranslator(original.store)
     rend.Page.__init__(self, original)
Beispiel #14
0
 def render_fileCabinet(self, ctx, data):
     return inevow.IQ(self.docFactory).onePattern('cabinet-iframe').fillSlots(
                 'src', ixmantissa.IWebTranslator(self.cabinet.store).linkTo(self.cabinet.storeID))
Beispiel #15
0
    def __init__(self, composer, recipients=None, subject=u'', messageBody=u'',
                 attachments=(), inline=False, parentMessage=None,
                 parentAction=None):
        """
        @type composer: L{Composer}

        @param recipients: email addresses of the recipients of this message.
        defaults to no recipients
        @type recipients: C{dict} which can contain any combination of the
        keys C{to}, C{cc} and C{bcc}, where the values are sequences of
        L{xquotient.mimeutil.EmailAddress} instances

        @param subject: the subject of this message
        @type subject: C{unicode}

        @param messageBody: the body of this message
        @type messageBody: C{unicode}

        @param attachments: the attachments of this message
        @type attachments: sequence of L{xquotient.mimepart.AttachmentPart}
        instances

        @param inline: whether the compose widget is being displayed inline,
        e.g. as a child of another widget
        @type inline: boolean

        @param parentMessage: The existing message this message is in
        response to, if any; otherwise None.

        @param parentAction: The status that should be set on the
        parent message, if any, once this message is delivered. Should
        be a value from L{xquotient.exmess} that ends in C{_STATUS}.

        C{toAddresses}, C{subject}, C{messageBody} and C{attachments} should
        be considered as presets - their values can be manipulated via the
        user interface
        """
        self.composer = composer
        self.cabinet = self.composer.store.findOrCreate(FileCabinet)
        self.translator = ixmantissa.IWebTranslator(composer.store)
        self._savedDraft = None
        super(ComposeFragment, self).__init__(
            callable=self._sendOrSave,
            parameters=[liveform.Parameter(name='fromAddress',
                                           type=liveform.TEXT_INPUT,
                                           coercer=self.translator.fromWebID),
                        liveform.Parameter(name='toAddresses',
                                           type=liveform.TEXT_INPUT,
                                           coercer=self._coerceEmailAddressString),
                        liveform.Parameter(name='subject',
                                           type=liveform.TEXT_INPUT,
                                           coercer=unicode),
                        liveform.Parameter(name='messageBody',
                                           type=liveform.TEXTAREA_INPUT,
                                           coercer=unicode),
                        liveform.Parameter(name='cc',
                                           type=liveform.TEXT_INPUT,
                                           coercer=self._coerceEmailAddressString),
                        liveform.Parameter(name='bcc',
                                           type=liveform.TEXT_INPUT,
                                           coercer=self._coerceEmailAddressString),
                        liveform.Parameter(name='draft',
                                           type=liveform.CHECKBOX_INPUT,
                                           coercer=bool)])
        if recipients is None:
            recipients = {}
        self.recipients = recipients
        self.subject = subject
        self.messageBody = messageBody
        self.attachments = attachments
        self.fileAttachments = []
        self.inline = inline

        self.docFactory = None
        self.parentMessage = parentMessage
        self.parentAction = parentAction