def get_claim_links(self, user): links = [] for guid, value in user.unclaimed_records.items(): obj = Guid.load(guid) url = f'{DOMAIN}user/{user._id}/{guid}/claim/?token={value["token"]}' links.append( f'Claim URL for {obj.content_type.model} {obj._id}: {url}') return links or [ 'User currently has no active unclaimed records for any nodes.' ]
def find_n_unread(cls, user, node, page, root_id=None): if node.is_contributor(user): if page == Comment.OVERVIEW: view_timestamp = user.get_node_comment_timestamps(target_id=node._id) root_target = Guid.load(node._id) elif page == Comment.FILES or page == Comment.WIKI: view_timestamp = user.get_node_comment_timestamps(target_id=root_id) root_target = Guid.load(root_id) else: raise ValueError('Invalid page') if not view_timestamp.tzinfo: view_timestamp = view_timestamp.replace(tzinfo=pytz.utc) return cls.objects.filter( Q(node=node) & ~Q(user=user) & Q(is_deleted=False) & (Q(date_created__gt=view_timestamp) | Q(date_modified__gt=view_timestamp)) & Q(root_target=root_target) ).count() return 0
def find_n_unread(cls, user, node, page, root_id=None): if node.is_contributor(user): if page == Comment.OVERVIEW: view_timestamp = user.get_node_comment_timestamps(target_id=node._id) root_target = Guid.load(node._id) elif page == Comment.FILES or page == Comment.WIKI: view_timestamp = user.get_node_comment_timestamps(target_id=root_id) root_target = Guid.load(root_id) else: raise ValueError('Invalid page') if not view_timestamp.tzinfo: view_timestamp = view_timestamp.replace(tzinfo=pytz.utc) return cls.objects.filter( Q(node=node) & ~Q(user=user) & Q(is_deleted=False) & (Q(created__gt=view_timestamp) | Q(modified__gt=view_timestamp)) & Q(root_target=root_target) ).count() return 0
def deconstruct_id(page): """ Backwards compatible code for use in writing to both _id field and action, resource, file, and version fields simultaneously. """ split = page.split(':') action = split[0] resource = Guid.load(split[1]) file = BaseFileNode.load(split[2]) if len(split) == 3: version = None else: version = split[3] return resource, file, action, version
def get_claim_links(self, user): links = [] for guid, value in user.unclaimed_records.items(): obj = Guid.load(guid) url = '{base_url}user/{uid}/{project_id}/claim/?token={token}'.format( base_url=DOMAIN, uid=user._id, project_id=guid, token=value['token']) links.append('Claim URL for {} {}: {}'.format( obj.content_type.model, obj._id, url)) return links or [ 'User currently has no active unclaimed records for any nodes.' ]