Exemplo n.º 1
0
    def getEvent(self, eventId, diffHours):
        context = self.context

        if eventId and eventId in context:
            event = context[eventId]
            startDate = event.startDate
            endDate = event.endDate

            members = []
            for memeber in event.attendees:
                principal = getPrincipal(memeber)
                oneMember = {}
                oneMember["key"] = memeber
                oneMember["value"] = principal.title
                members.append(oneMember)

            if diffHours:
                startDate = startDate + timedelta(hours=int(diffHours))
                endDate = endDate + timedelta(hours=int(diffHours))

            info = {
                'event': event,
                'sdDate': startDate.strftime('%m/%d/%Y'),
                'sdTime': startDate.strftime('%H:%M'),
                'edDate': endDate.strftime('%m/%d/%Y'),
                'edTime': endDate.strftime('%H:%M'),
                'members': members}
            return info

        return
Exemplo n.º 2
0
    def getUserInfo(self, loginOrId):
        """Return the user name details, and avatar url for given userid"""

        principal = getPrincipal(loginOrId)
        if principal is None:
            principal = getPrincipalByLogin(loginOrId)

        if principal is not None:
            profile = IPersonalProfile(principal, None)
            homeFolder = IPersonalSpace(principal, None)
            profileUrl = homeFolder is not None and '%s/profile/'%absoluteURL(homeFolder, self.request) or ''

            if profile.avatar is not None:
                iconURL = '%s/profile.avatar/%s' % (absoluteURL(getSite(), self.request), principal.id)
            else:
                iconURL = '%sprofileImage' % profileUrl

            return {'username' : loginOrId,
                    'fullname' : principal.title,
                    'email' : profile.email,
                    'home_page' : profileUrl,
                    'location' : profileUrl,
                    'description' : principal.description,
                    'portrait_url' : iconURL
                    }
        else:
            raise ValueError("User %s Does not Exist!" % loginOrId)
Exemplo n.º 3
0
    def getTaskCommits(self, task):
        """ returns comments for task """

        catalog = getCatalog()
        comments = catalog.search(contexts=(task,))[:3]

        if comments:
            result = []
            for item in comments:
                principal = getPrincipal(item.author)
                homeFolder = IPersonalSpace(principal, None)
                profileUrl = homeFolder is not None \
                        and '%s/profile/'%absoluteURL(homeFolder, self.request) or ''

                # limit text length
                text = getMultiAdapter((item, self.request), ITextAnnotation).getText(text=item.comment)

                info = {
                    'text': text,
                    'author': principal and principal.title or u'Unknown',
                    'author_url': profileUrl
                }
                result.append(info)

            return result
Exemplo n.º 4
0
 def __call__(self):
     preference = IGeotargetingPreference(getPrincipal(), None)
     if preference is not None and preference.enabled \
         and preference.location is not None \
         and preference.location \
         and preference.location.geocode is not None \
         and preference.location.geocode:
         return {'geotargeting': {'location': {'any_of': (preference.location.geocode,)}}}
     return {}
Exemplo n.º 5
0
    def update(self):
        super(EventNotification, self).update()

        context = removeAllProxies(self.context)
        request = self.request
        principal = self.request.principal
        ids = getUtility(IIntIds)

        self.name = context.__name__

        mailer = getUtility(IMailer)

        profile = IPersonalProfile(principal, None)
        if profile is not None and profile.email:
            author = profile.title
            self.author = author
            self.addHeader(u'To', formataddr((author, profile.email),))
        else:
            self.author = principal.title or principal.id

        self.addHeader(u'From', formataddr((self.author, mailer.email_from_address),))

        self.addHeader(u'In-Reply-To', u'<*****@*****.**>'%ids.getId(context))

        self.url = u'%s/'%absoluteURL(context, request)
        self.title = u'%s'%context.title
        self.calendar = context.__parent__

        # calendar
        self.calendarUrl = u'%s/'%absoluteURL(self.calendar, request)

        # owner
        self.owner = IOwnership(context).owner

        members = []
        for member in context.attendees:
            principal = getPrincipal(member)
            oneMember = {}

            homeFolder = IPersonalSpace(principal, None)
            profileUrl = homeFolder is not None \
                and '%s/profile/'%absoluteURL(homeFolder, request) or ''

            oneMember["url"] = profileUrl
            oneMember["title"] = principal.title
            members.append(oneMember)

        info = {
            'event': context,
            'sdDate': context.startDate.strftime('%m/%d/%Y'),
            'sdTime': context.startDate.strftime('%H:%M'),
            'edDate': context.endDate.strftime('%m/%d/%Y'),
            'edTime': context.endDate.strftime('%H:%M'),
            'members': members}

        self.info = info
Exemplo n.º 6
0
 def getUser(self, uid):
     principal = getPrincipal(uid)
     try:
         profile = IPersonalProfile(principal)
         return dict(
             title=profile.title,
             url=profile.space is not None and u'%s/' % absoluteURL(
                 profile.space, self.request))
     except TypeError:
         return dict(title='Deleted Member', url='#')
Exemplo n.º 7
0
    def getMemberInfo(self, attendees):
        if attendees is None:
            return

        members = []
        for member in attendees:
            principal = getPrincipal(member)
            oneMember = {}

            homeFolder = IPersonalSpace(principal, None)
            profileUrl = homeFolder is not None \
                and '%s/profile/'%absoluteURL(homeFolder, self.request) or ''

            oneMember["url"] = profileUrl
            oneMember["title"] = principal.title
            members.append(oneMember)

        return members
Exemplo n.º 8
0
def taggableModified(ob, event):
    if component.getUtility(IPersonalTagsConfiglet).useGlobalTags:
        tags = IContentTags(ob).tags
        principal = getPrincipal()
        if principal is not None:
            component.getMultiAdapter((ob, principal), IContentPersonalTags).tags = tags
Exemplo n.º 9
0
    def listCalendarByRange(self, first_date, last_date):
        """ """
        catalog = getUtility(ICatalog)

        ret = {}
        ret['events'] = []
        ret["issort"] = True
        ret["start"] = first_date.strftime('%m/%d/%Y %H:%M')
        ret["end"] = last_date.strftime('%m/%d/%Y %H:%M')
        ret['error'] = None

        if self.diffHours:
            first_date = first_date - timedelta(hours=int(self.diffHours))
            last_date = last_date - timedelta(hours=int(self.diffHours))

        # select events from calendar within range:
        results = catalog.searchResults(
            traversablePath = {'any_of': (self.context,)},
            typeType = {'any_of': ('Event type',)},
            calendarEventDuration = {
                'between': (first_date, last_date, True, True)})

        events = ""
        for i in results:

            members = []
            if i.attendees:
                for member in i.attendees:
                    principal = getPrincipal(member)

                    homeFolder = IPersonalSpace(principal, None)
                    profileUrl = homeFolder is not None \
                        and '%s/profile/'%absoluteURL(homeFolder, self.request) or ''

                    members.append('<a href="%s">%s</a>'%(profileUrl, principal.title))

            text = getattr(i.text,'cooked', '')
            startDate = i.startDate
            endDate = i.endDate

            if self.diffHours:
                startDate = startDate + timedelta(hours=int(self.diffHours))
                endDate = endDate + timedelta(hours=int(self.diffHours))

            ret['events'].append([
                i.__name__,
                i.title,
                startDate.strftime('%m/%d/%Y %H:%M'),
                endDate.strftime('%m/%d/%Y %H:%M'),
                i.isAllDayEvent,
                0, #more than one day event
                   #InstanceType,
                i.recurringRule,
                i.color,
                1, #editable
                i.location,
                i.description,
                urllib.quote(', '.join(members)), #attends
                i.eventUrl,
                i.contactName,
                i.contactEmail,
                i.contactPhone,
                text #i.text
                ])

        return encoder.encode(ret)
Exemplo n.º 10
0
def getEmailById(principalId):
    principal = getPrincipal(principalId)
    if principal is not None:
        profile = IPersonalProfile(principal)
        return profile.email
 def listSubscribers(self, notification):
     profiles = [IPersonalProfile(getPrincipal(subscriber)) for subscriber in
                 notification.getSubscribers(self.context) if getPrincipal(subscriber) is not None]
     return [(profile.title, absoluteURL(profile.space, self.request)) for profile in profiles]
Exemplo n.º 12
0
 def getAuthor(self):
     comment = self.contexts[1]
     return getPrincipal(comment.author)
Exemplo n.º 13
0
def taggableModified(ob, event):
    if not component.getUtility(IPersonalFriendConnectConfiglet).useGlobalTags:
        return
    tags = IContentTags(ob).tags
    component.getMultiAdapter((ob, getPrincipal()), IPersonalFriendConnect).tags = tags
Exemplo n.º 14
0
 def isAvailable(self):
     preference = IGeotargetingPreference(getPrincipal(), None)
     if preference is not None:
         return preference.enabled
Exemplo n.º 15
0
 def getPrincipal(self):
     return getPrincipal(self.__principal__)