Пример #1
0
def render_action(action):
    if isinstance(action, Comment):
        comment = action.text
        user = action.user
        comment += "<br/>Comment from %s by %s" % (prettyDate(action.date), user)
    else:
        fields = action.getChangedFields()
        if not fields:
            return ''
        for field in ['Sort_Index', 'Parentid']:
            if field in fields:
                fields.remove(field)
        if not fields:
            return ''
        if "Num_Children" in fields:
            fields.remove("Num_Children")
        if 'Statusid' in fields:
            fields.remove('Statusid')
            fields.append('Status')
        if 'Text' in fields:
            fields.remove('Text')
            fields.append('Description')
        user = action.updatedBy
        comment = "%s updated %s by %s" % (", ".join (fields), prettyDate(action.dateArchived), user)
    return comment
Пример #2
0
 def pretty_mod_date(self, version):
     if isinstance(version, dict):
         value = version['modification_date']
     else:
         try:
             value = DateTime(version.sys_metadata['timestamp'])
         except AttributeError:
             value = version
     return prettyDate(value)
Пример #3
0
 def getUserInfo(self):
     """Returns a dict with user info that gets displayed on profile view"""
     if self.info is None:
         mtool = getToolByName(self.context, "portal_membership")
         miv = getMultiAdapter((self.context, self.request), name="member_info")
         member, memberfolder = miv.member, miv.member_folder
         self.info = dict(
             login=member.getId(),
             fullname=member.getFullname(),
             membersince=prettyDate(member.created()),
             lastlogin=prettyDate(member.getLast_login_time()),
             location=member.getLocation(),
             prefsurl=member.absolute_url() + "/edit",
             portraiturl=self._getPortraitURL(member),
             projects=member.getProjects(),  # @@@ this should be indexed and then returned by a catalog call
             wiki=self._getWiki(memberfolder),
             editpermission=mtool.checkPermission(ModifyPortalContent, self.context),
             isme=member == mtool.getAuthenticatedMember(),
         )
     return self.info
Пример #4
0
def home(request):
    chrome = {}

    recently_created_projects = utils.projects_recently_created()
    chrome.update({
            'news': [
                utils.FeedEntry()
                for news in utils.recent_news_items()
                ],
            'newest_projects': [
                utils.FeedEntry(project['url'], project['name'], 
                                project['description'],
                                item_data=[
                        _("created %(date)s by %(user_link)s") % {
                            'date': prettyDate(project['created']),
                            'user_link': project['creator']['user_link'],
                            },
                        ],
                                image_url=project['logo'],
                                image_class="oc-project-logo",
                                )
                for project in recently_created_projects
                ],
            'updated_projects': [
                utils.FeedEntry(project['url'], project['name'], 
                                project['description'],
                                item_data=[
                        _("%(num_members)s members") % {
                            'num_members': project['num_members']},
                        _("last updated %(date)s") % {
                            'date': prettyDate(project['updated'])},
                        ],
                                image_url=project['logo'],
                                image_class="oc-project-logo",
                                )
                for project in utils.projects_recently_updated(exclude=[
                        project['slug'] for project in recently_created_projects])
                ],
            })
    return chrome
Пример #5
0
def people(request):
    chrome = {}
    chrome.update({
            'recent_members': [
                utils.FeedEntry(person['url'], person['fullname'], 
                                person['about'],
                                item_data=[
                        person['location'],
                        _("Member since %(date)s") % {'date': prettyDate(person['created'])},
                        ],
                                image_url=person['logo'],
                                image_class="photo",
                                )
                for person in utils.people_recently_created()],
            })
    return chrome
Пример #6
0
def projects(request):
    chrome = {}
    chrome.update({
            'updated_projects': [
                utils.FeedEntry(project['url'], project['name'], 
                                project['description'],
                                item_data=[
                        _("%(num_members)s members, last updated %(date)s") % {
                            'num_members': project['num_members'],
                            'date': prettyDate(project['updated'])},
                        ],
                                image_url=project['logo'],
                                image_class="oc-project-logo",
                                )
                for project in utils.projects_recently_updated(limit=10)],
            })
    return chrome
Пример #7
0
 def dictify(brain):
     d = dict(title = brain.Title,
              url   = brain.getURL(),
              date  = prettyDate(DateTime(brain.ModificationDate)))
     brainpath = brain.getPath()
     if brainpath.startswith(pfolderpath):
         # page brain inside a project
         remainder = brainpath[len(pfolderpath)+1:]
         remsplit = remainder.split('/')
         projid = remsplit[0]
         d['projurl'] = '%s/%s' % (pfolderurl, projid)
         projpath = '%s/%s' % (pfolderpath, projid)
         projmeta = self.catalog.getMetadataForUID(projpath)
         d['project'] = projmeta['Title']
     else:
         # page brain not inside a project
         d.update(project=None, projurl=None)
     return d
Пример #8
0
def render_actions(actions, cutoff=5):
    if cutoff == 0:
        cutoff = len(actions)
    rendered_actions = []

    count = 0
    for action in actions:
        if not isinstance(action, Comment) and 'Created' in action.getChangedFields():
            user = action.updatedBy
            result = "Created %s by %s" % (prettyDate(action.dateArchived), user)
        else:
            result = render_action(action)
            if not result:
                continue
        count += 1
        rendered_actions.append(result)
        if count >= cutoff:
            break

    if not rendered_actions:
        return ''
    head = "\n".join ("<li>%s<hr></li>\n" % action for action in rendered_actions[:-1])
    return "%s\n<li>%s</li>" % (head, rendered_actions[-1])
Пример #9
0
 def lastModifiedTime(self):
     return prettyDate(self.context.ModificationDate())
Пример #10
0
 def pretty_date(self, date):
     return prettyDate(date)
Пример #11
0
 def pretty_date(self, date):
     # XXX this is copy/pasted
     return prettyDate(date)
Пример #12
0
 def pretty_date(self, date, include_time=False):
     return prettyDate(date, include_time)
Пример #13
0
 def dob(self):
     return prettyDate(self.portal.created())
Пример #14
0
    def member_info_for_member(self, member):
        if member == None:
            # Not logged in.
            return {}
        id = member.getId()
        result = {'id': id}
        folder = self.membertool.getHomeFolder(id)
        if folder:
            # we only add a URL to the result dict if the member folder exists.
            # if the folder does not exist, that means that the member has never
            # logged in (since member folders are created on first login, after
            # account confirmation)
            # if the folder does not exist, we have no good link to the member
            # so we just don't provide one
            result['url'] = folder.absolute_url()
            result['absolute_url'] = folder.absolute_url()

        if IReMember.providedBy(member):
            logintime = member.getLogin_time()
            if logintime == DateTime.DateTime('2000/01/01'): # XXX hack around zope
                logintime = 'never'
            else:
                logintime = logintime and prettyDate(logintime) or 'member.getLogin_time() is None?'
            
            result.update(
                id          = id,
                Title       = member.Title(),
                fullname    = member.getFullname(),
                email       = member.getEmail(),
                membersince = prettyDate(member.creation_date),
                lastlogin   = logintime,
                folder_url  = self.memfolder_url(id_=id),
                home_url    = self.memhome_url(id_=id),
                projects    = self.project_brains_for(member),
                location    = member.getLocation(),
                statement   = member.getStatement(),
                background  = member.getBackground(),
                skills      = member.getSkills(),
                affiliations= member.getAffiliations(),
                website     = member.getWebsite(),
                favorites   = member.getFavorites(),
                anon_email  = member.getUseAnonByDefault(),
                )
        else:
            # XXX TODO 
            # we're an old school member object, e.g. an admin user
            result.update(fullname=member.fullname)

            for key in 'membersince', 'lastlogin','location', \
                    'statement', 'affiliations', 'skills', \
                    'background',  'url', 'favorites', 'folder_url':
                result[key] = ''

        folder = self.membertool.getHomeFolder(result['id'])
        if folder:
            result['url'] = folder.absolute_url()

        # @@ DWM: should be in an adapter or on the member object
        result['portrait_url'] = self.defaultPortraitURL
        portrait = member.getProperty('portrait', None)
        if portrait:
            result['portrait_url'] = portrait.absolute_url()
            result['portrait_thumb_url'] = "%s_thumb" %portrait.absolute_url()
            result['portrait_width'] = str(portrait.width)
        else:
            result['portrait_thumb_url'] = self.defaultPortraitThumbURL
            result['portrait_width'] = '200' # XXX don't hard code width of default portrait

        # XXX We should do something like the following to avoid
        # potential UnicodeDecodeErrors all over the place; But lots
        # of tests are wired to expect str output and I don't have
        # time to chase those down and decide if I'm right.  - Paul W.
#         for key, val in result.items():
#             # Much of this came from archetypes data, which
#             # horrifically stores everything as encoded bytes...decode
#             # it to be safe.
#             if isinstance(val, str):
#                 try:
#                     result[key] = val.decode('utf-8')
#                 except UnicodeDecodeError:
#                     # XXX we have non-utf8 data? dunno what to do then.
#                     pass
        return result
Пример #15
0
 def pretty_date(self):
     return prettyDate(self.context)
Пример #16
0
def readableDate(date):
    if date:
        return prettyDate(date)
    else:
        return "No deadline"