|
a/Allura/allura/model/artifact.py |
|
b/Allura/allura/model/artifact.py |
|
... |
|
... |
571 |
author_link = FieldProperty(str, if_missing=lambda:c.user.url() if hasattr(c, 'user') else None)
|
571 |
author_link = FieldProperty(str, if_missing=lambda:c.user.url() if hasattr(c, 'user') else None)
|
572 |
artifact_reference = FieldProperty(S.Deprecated)
|
572 |
artifact_reference = FieldProperty(S.Deprecated)
|
573 |
|
573 |
|
574 |
|
574 |
|
575 |
@classmethod
|
575 |
@classmethod
|
576 |
def post(cls, artifact, title=None, description=None, author=None):
|
576 |
def post(cls, artifact, title=None, description=None, author=None, author_link=None, author_name=None):
|
577 |
"Create a Feed item"
|
577 |
"""
|
|
|
578 |
Create a Feed item. Returns the item.
|
|
|
579 |
But if anon doesn't have read access, create does not happen and None is returned
|
|
|
580 |
"""
|
578 |
# TODO: fix security system so we can do this correctly and fast
|
581 |
# TODO: fix security system so we can do this correctly and fast
|
579 |
from allura import model as M
|
582 |
from allura import model as M
|
580 |
anon = M.User.anonymous()
|
583 |
anon = M.User.anonymous()
|
581 |
if not security.has_access(artifact, 'read', user=anon):
|
584 |
if not security.has_access(artifact, 'read', user=anon):
|
582 |
return
|
585 |
return
|
583 |
if not security.has_access(c.project, 'read', user=anon):
|
586 |
if not security.has_access(c.project, 'read', user=anon):
|
584 |
return
|
587 |
return
|
585 |
idx = artifact.index()
|
588 |
idx = artifact.index()
|
|
|
589 |
if author is None:
|
|
|
590 |
author = c.user
|
|
|
591 |
if author_name is None:
|
|
|
592 |
author_name = author.get_pref('display_name')
|
586 |
if title is None:
|
593 |
if title is None:
|
587 |
title='%s modified by %s' % (idx['title_s'], c.user.get_pref('display_name'))
|
594 |
title='%s modified by %s' % (idx['title_s'], author_name)
|
588 |
if description is None: description = title
|
595 |
if description is None: description = title
|
589 |
if author is None: author = c.user
|
|
|
590 |
item = cls(
|
596 |
item = cls(
|
591 |
ref_id=artifact.index_id(),
|
597 |
ref_id=artifact.index_id(),
|
592 |
neighborhood_id=artifact.app_config.project.neighborhood_id,
|
598 |
neighborhood_id=artifact.app_config.project.neighborhood_id,
|
593 |
project_id=artifact.app_config.project_id,
|
599 |
project_id=artifact.app_config.project_id,
|
594 |
app_config_id=artifact.app_config_id,
|
600 |
app_config_id=artifact.app_config_id,
|
595 |
tool_name=artifact.app_config.tool_name,
|
601 |
tool_name=artifact.app_config.tool_name,
|
596 |
title=title,
|
602 |
title=title,
|
597 |
description=description,
|
603 |
description=description,
|
598 |
link=artifact.url(),
|
604 |
link=artifact.url(),
|
599 |
author_name=author.get_pref('display_name'),
|
605 |
author_name=author_name,
|
600 |
author_link=author.url())
|
606 |
author_link=author_link or author.url())
|
601 |
return item
|
607 |
return item
|
602 |
|
608 |
|
603 |
@classmethod
|
609 |
@classmethod
|
604 |
def feed(cls, q, feed_type, title, link, description,
|
610 |
def feed(cls, q, feed_type, title, link, description,
|
605 |
since=None, until=None, offset=None, limit=None):
|
611 |
since=None, until=None, offset=None, limit=None):
|