コード例 #1
0
    def __init__(self, definition_file, archive_file=None, owner=None):
        """
        Initialize collection processor
        :param definition_file: yaml configuration for `archive_file`
        :param archive_file: when file is uploaded using a web form then
            `archive_file` is `UploadedFile` instance; if it is preselected
            from a list of external media then it is a *full path* to a file
        :param owner: instance of a user
        """
        self.resource_model = apps.get_model('storage', 'Resource')
        self.definition_file = definition_file
        self.definition_data = self.process_definition()
        self.definition = None

        if isinstance(archive_file, basestring):
            archive_file = open(archive_file, 'rb')

        self.archive_file = archive_file
        self.archive = None
        self.owner = owner
        self.owner_display = get_pretty_username(user=owner)
        self.separator = None
        self.deployments = {}
        self.collections_processed = {}
        self.errors = {}
コード例 #2
0
def pretty_username_filter(user):
    """
    Filter version of pretty_username templatetag

    :param user: User model instance
    :return: prettyfied version of username
    """
    return get_pretty_username(user=user)
コード例 #3
0
def pretty_username(user):
    """This templatetag is used because data is stored on User model
    and it's more efficient way than going through UserProfile

    :param user: User model instance
    :return: prettyfied version of username
    """
    return get_pretty_username(user=user)
コード例 #4
0
 def get_context_data(self, **kwargs):
     context = {
         'data_url':
         reverse('geomap:api-map-list'),
         'owners':
         set([
             get_pretty_username(user=user)
             for user in User.objects.exclude(owned_maps__isnull=True)
         ]),
         'model_name':
         'maps'
     }
     return {'map_context': context}
コード例 #5
0
ファイル: serializers.py プロジェクト: yvanss/trapper
 def get_roles(self, item):
     roles_list = []
     for user, role_list in item.get_roles().items():
         roles = [role.get_name_display() for role in role_list]
         roles.sort()
         roles_list.append({
             'user':
             get_pretty_username(user=user),
             'profile':
             reverse('accounts:show_profile',
                     kwargs={'username': user.username}),
             'roles':
             roles
         })
     roles_list.sort(key=lambda x: x['user'])
     return roles_list
コード例 #6
0
    def get_roles(self, item):
        """Custom method for retrieving list of roles connected to given
        classification project. Each role contain:

        * user (prettified version)
        * profile url
        * list of role names that user has in project
        """
        roles_list = []
        for user, role_list in item.get_roles().items():
            roles = [role.get_name_display() for role in role_list]
            roles.sort()
            roles_list.append({
                'user':
                get_pretty_username(user=user),
                'profile':
                reverse('accounts:show_profile',
                        kwargs={'username': user.username}),
                'roles':
                roles
            })
        roles_list.sort(key=lambda x: x['user'])
        return roles_list
コード例 #7
0
ファイル: serializers.py プロジェクト: yvanss/trapper
 def get_name(self, item):
     """Custom method for retrieving prettified username"""
     return get_pretty_username(user=item)
コード例 #8
0
 def __unicode__(self):
     """By default printing profile should display pretty version
     of username"""
     return get_pretty_username(user=self.user)
コード例 #9
0
 def to_representation(self, obj):
     return get_pretty_username(obj)
コード例 #10
0
 def label_from_instance(self, obj):
     """Use :func:`apps.accounts.utils.get_pretty_username`
     to prettify username"""
     return get_pretty_username(user=obj)