예제 #1
0
파일: misc.py 프로젝트: lorenanicole/OTM2
def edits(request, instance):
    """
    Request a variety of different audit types.
    Params:
       - models
         Comma separated list of models (only Tree and Plot are supported)
       - model_id
         The ID of a specfici model. If specified, models must also
         be defined and have only one model

       - user
         Filter by a specific user

       - exclude (default: true)
         Set to false to ignore edits that are currently pending

       - page_size
         Size of each page to return (up to PAGE_MAX)
       - page
         The page to return
    """
    (page, page_size, models, model_id,
     exclude_pending) = get_audits_params(request)

    user_id = request.GET.get('user', None)
    user = None

    if user_id is not None:
        user = User.objects.get(pk=user_id)

    return get_audits(request.user, instance, request.REQUEST, user, models,
                      model_id, page, page_size, exclude_pending)
예제 #2
0
def edits(request, instance):
    """
    Request a variety of different audit types.
    Params:
       - models
         Comma separated list of models (only Tree and Plot are supported)
       - model_id
         The ID of a specfici model. If specified, models must also
         be defined and have only one model

       - user
         Filter by a specific user

       - exclude (default: true)
         Set to false to ignore edits that are currently pending

       - page_size
         Size of each page to return (up to PAGE_MAX)
       - page
         The page to return
    """
    (page, page_size, models, model_id,
     exclude_pending) = get_audits_params(request)

    user_id = request.GET.get('user', None)
    user = None

    if user_id is not None:
        user = User.objects.get(pk=user_id)

    return get_audits(request.user, instance, request.REQUEST, user,
                      models, model_id, page, page_size, exclude_pending)
예제 #3
0
def user(request, username):
    user = get_object_or_404(User, username=username)
    instance_id = request.GET.get("instance_id", None)

    instance = get_instance_or_404(pk=instance_id) if instance_id else None

    query_vars = {"instance_id": instance_id} if instance_id else {}

    models = get_filterable_audit_models().values()
    audit_dict = get_audits(request.user, instance, query_vars, user, models, 0, should_count=True)

    reputation = user.get_reputation(instance) if instance else None

    public_fields = []
    private_fields = []

    for field in USER_PROFILE_FIELDS.values():
        field_tuple = (field["label"], field["identifier"], field.get("template", "treemap/field/div.html"))
        if field["visibility"] == "public" and user.make_info_public is True:
            public_fields.append(field_tuple)
        else:
            private_fields.append(field_tuple)

    return {
        "user": user,
        "reputation": reputation,
        "instance_id": instance_id,
        "instances": get_user_instances(request.user, user, instance),
        "total_edits": audit_dict["total_count"],
        "audits": audit_dict["audits"],
        "next_page": audit_dict["next_page"],
        "public_fields": public_fields,
        "private_fields": private_fields,
    }
예제 #4
0
def user(request, username):
    user = get_object_or_404(User, username=username)
    instance_id = request.GET.get('instance_id', None)

    instance = (get_instance_or_404(pk=instance_id)
                if instance_id else None)

    query_vars = {'instance_id': instance_id} if instance_id else {}

    models = get_filterable_audit_models().values()
    audit_dict = get_audits(request.user, instance, query_vars,
                            user, models, 0, should_count=True)

    reputation = user.get_reputation(instance) if instance else None

    public_fields = []
    private_fields = []

    for field in USER_PROFILE_FIELDS.values():
        field_tuple = (field['label'], field['identifier'],
                       field.get('template', "treemap/field/div.html"))
        if field['visibility'] == 'public' and user.make_info_public is True:
            public_fields.append(field_tuple)
        else:
            private_fields.append(field_tuple)

    return {'user': user,
            'reputation': reputation,
            'instance_id': instance_id,
            'instances': get_user_instances(request.user, user, instance),
            'total_edits': audit_dict['total_count'],
            'audits': audit_dict['audits'],
            'next_page': audit_dict['next_page'],
            'public_fields': public_fields,
            'private_fields': private_fields}
예제 #5
0
def user_audits(request, username):
    user = get_object_or_404(User, username=username)
    instance_id = request.GET.get("instance_id", None)

    instance = get_instance_or_404(pk=instance_id) if instance_id else None

    (page, page_size, models, model_id, exclude_pending) = get_audits_params(request)

    return get_audits(request.user, instance, request.REQUEST, user, models, model_id, page, page_size, exclude_pending)
예제 #6
0
def user_audits(request, username):
    user = get_object_or_404(User, username=username)
    instance_id = request.GET.get('instance_id', None)

    instance = (get_instance_or_404(pk=instance_id)
                if instance_id else None)

    params = get_audits_params(request)

    return get_audits(request.user, instance, request.GET.copy(), user=user,
                      **params)
예제 #7
0
파일: user.py 프로젝트: lorenanicole/OTM2
def user_audits(request, username):
    user = get_object_or_404(User, username=username)
    instance_id = request.GET.get('instance_id', None)

    instance = (get_instance_or_404(pk=instance_id) if instance_id else None)

    (page, page_size, models, model_id,
     exclude_pending) = get_audits_params(request)

    return get_audits(request.user, instance, request.REQUEST, user, models,
                      model_id, page, page_size, exclude_pending)
예제 #8
0
파일: user.py 프로젝트: lorenanicole/OTM2
def user(request, username):
    user = get_object_or_404(User, username=username)
    instance_id = request.GET.get('instance_id', None)

    instance = (get_instance_or_404(pk=instance_id) if instance_id else None)

    query_vars = {'instance_id': instance_id} if instance_id else {}

    models = get_filterable_audit_models().values()
    audit_dict = get_audits(request.user,
                            instance,
                            query_vars,
                            user,
                            models,
                            0,
                            should_count=True)

    reputation = user.get_reputation(instance) if instance else None

    favorites_qs = Favorite.objects.filter(user=user).order_by('-created')
    favorites = [{
        'map_feature': f.map_feature,
        'title': title_for_map_feature(f.map_feature),
        'instance': f.map_feature.instance,
        'address': f.map_feature.address_full,
        'photo': _small_feature_photo_url(f.map_feature)
    } for f in favorites_qs]

    public_fields = []
    private_fields = []

    for field in USER_PROFILE_FIELDS.values():
        field_tuple = (field['label'], field['identifier'],
                       field.get('template', "treemap/field/div.html"))
        if field['visibility'] == 'public' and user.make_info_public is True:
            public_fields.append(field_tuple)
        else:
            private_fields.append(field_tuple)

    return {
        'user': user,
        'its_me': user.id == request.user.id,
        'reputation': reputation,
        'instance_id': instance_id,
        'instances': get_user_instances(request.user, user, instance),
        'total_edits': audit_dict['total_count'],
        'audits': audit_dict['audits'],
        'next_page': audit_dict['next_page'],
        'public_fields': public_fields,
        'private_fields': private_fields,
        'favorites': favorites
    }
예제 #9
0
def user_audits(request, username):
    user = get_object_or_404(User, username=username)
    instance_id = request.GET.get('instance_id', None)

    instance = (get_instance_or_404(pk=instance_id) if instance_id else None)

    params = get_audits_params(request)

    return get_audits(request.user,
                      instance,
                      request.GET.copy(),
                      user=user,
                      **params)
예제 #10
0
def user(request, username):
    user = get_object_or_404(User, username=username)
    instance_id = request.GET.get('instance_id', None)

    instance = (get_instance_or_404(pk=instance_id)
                if instance_id else None)

    query_vars = QueryDict(mutable=True)
    if instance_id:
        query_vars['instance_id'] = instance_id

    audit_dict = get_audits(request.user, instance, query_vars,
                            user=user, should_count=True)

    reputation = user.get_reputation(instance) if instance else None

    favorites_qs = Favorite.objects.filter(user=user).order_by('-created')
    favorites = [{
        'map_feature': f.map_feature,
        'title': f.map_feature.title(),
        'instance': f.map_feature.instance,
        'address': f.map_feature.address_full,
        'photo': _small_feature_photo_url(f.map_feature)
    } for f in favorites_qs]

    public_fields = []
    private_fields = []

    for field in USER_PROFILE_FIELDS.values():
        field_tuple = (field['label'], field['identifier'],
                       field.get('template', "treemap/field/div.html"))
        if field['visibility'] == 'public' and user.make_info_public is True:
            public_fields.append(field_tuple)
        else:
            private_fields.append(field_tuple)

    return {'user': user,
            'its_me': user.id == request.user.id,
            'reputation': reputation,
            'instance_id': instance_id,
            'instances': get_user_instances(request.user, user, instance),
            'total_edits': audit_dict['total_count'],
            'audits': audit_dict['audits'],
            'next_page': audit_dict['next_page'],
            'public_fields': public_fields,
            'private_fields': private_fields,
            'favorites': favorites}