Added search to userView

This commit is contained in:
Fergal Moran
2013-07-02 21:24:13 +01:00
parent 7da8c92db9
commit fbbb395c7f
779 changed files with 77 additions and 30 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
README Normal file → Executable file
View File

0
_working/create Normal file → Executable file
View File

0
_working/get_downloads.sql Normal file → Executable file
View File

0
_working/get_plays.sql Normal file → Executable file
View File

0
apache/django_live.wsgi Normal file → Executable file
View File

0
core/__init__.py Normal file → Executable file
View File

0
core/analytics/__init__.py Normal file → Executable file
View File

0
core/analytics/google.py Normal file → Executable file
View File

0
core/decorators.py Normal file → Executable file
View File

0
core/serialisers/__init__.py Normal file → Executable file
View File

0
core/serialisers/json.py Normal file → Executable file
View File

0
core/tasks.py Normal file → Executable file
View File

0
core/tests/__init__.py Normal file → Executable file
View File

0
core/tests/mix.py Normal file → Executable file
View File

0
core/utils/__init__.py Normal file → Executable file
View File

0
core/utils/audio/__init__.py Normal file → Executable file
View File

0
core/utils/audio/mp3.py Normal file → Executable file
View File

0
core/utils/file.py Normal file → Executable file
View File

0
core/utils/html.py Normal file → Executable file
View File

0
core/utils/live.py Normal file → Executable file
View File

0
core/utils/string.py Normal file → Executable file
View File

0
core/utils/url.py Normal file → Executable file
View File

0
core/utils/waveform.py Normal file → Executable file
View File

0
core/widgets/__init__.py Normal file → Executable file
View File

0
core/widgets/upload.py Normal file → Executable file
View File

0
dss/__init__.py Normal file → Executable file
View File

0
dss/localsettings.initial.py Normal file → Executable file
View File

0
dss/logsettings.py Normal file → Executable file
View File

0
dss/settings.py Normal file → Executable file
View File

0
dss/urls.py Normal file → Executable file
View File

0
dss/warning_settings.py Normal file → Executable file
View File

0
dss/wsgi.py Normal file → Executable file
View File

0
index.html Normal file → Executable file
View File

0
manage.py Normal file → Executable file
View File

0
pip_upgrade.py Normal file → Executable file
View File

0
requirements.txt Normal file → Executable file
View File

0
spa/__init__.py Normal file → Executable file
View File

0
spa/admin.py Normal file → Executable file
View File

0
spa/ajax.py Normal file → Executable file
View File

0
spa/api/__init__.py Normal file → Executable file
View File

0
spa/api/v1/ActivityResource.py Normal file → Executable file
View File

0
spa/api/v1/BackboneCompatibleResource.py Normal file → Executable file
View File

0
spa/api/v1/ChatResource.py Normal file → Executable file
View File

0
spa/api/v1/CommentResource.py Normal file → Executable file
View File

0
spa/api/v1/EventResource.py Normal file → Executable file
View File

18
spa/api/v1/MixResource.py Normal file → Executable file
View File

@@ -130,17 +130,19 @@ class MixResource(BackboneCompatibleResource):
return obj_list
def apply_filters(self, request, applicable_filters):
semi_filtered = super(MixResource, self).apply_filters(request, applicable_filters).filter(
waveform_generated=True)
type = request.GET.get('type', None)
user = request.GET.get('user', None)
if type == 'favourites':
semi_filtered = super(MixResource, self)\
.apply_filters(request, applicable_filters)\
.filter(waveform_generated=True)
f_type = request.GET.get('type', None)
f_user = request.GET.get('user', None)
if f_type == 'favourites':
semi_filtered = semi_filtered.filter(favourites__user=request.user.get_profile())
elif type == 'likes':
elif f_type == 'likes':
semi_filtered = semi_filtered.filter(likes__user=request.user.get_profile())
if user is not None:
semi_filtered = semi_filtered.filter(user__slug=user)
if f_user is not None:
semi_filtered = semi_filtered.filter(user__slug=f_user)
return semi_filtered

0
spa/api/v1/ReleaseAudioResource.py Normal file → Executable file
View File

0
spa/api/v1/ReleaseResource.py Normal file → Executable file
View File

15
spa/api/v1/UserResource.py Normal file → Executable file
View File

@@ -1,6 +1,6 @@
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.db.models import Count
from django.db.models import Count, Q
from tastypie import fields
from tastypie.authentication import Authentication
from tastypie.authorization import DjangoAuthorization
@@ -97,6 +97,7 @@ class UserProfileResource(BackboneCompatibleResource):
def dehydrate_mix_count(self, bundle):
return bundle.obj.mixes.count()
class UserResource(BackboneCompatibleResource):
profile = fields.ToOneField(UserProfileResource, attribute='userprofile', related_name='user', full=True)
@@ -119,6 +120,18 @@ class UserResource(BackboneCompatibleResource):
self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
]
def apply_filters(self, request, applicable_filters):
semi_filtered = super(UserResource, self).apply_filters(request, applicable_filters)
q = request.GET.get('q', None)
if q is not None:
semi_filtered = semi_filtered.filter(
Q(first_name__icontains=q) |
Q(last_name__icontains=q) |
Q(username__icontains=q)
)
return semi_filtered
def apply_sorting(self, obj_list, options=None):
return super(UserResource, self).apply_sorting(obj_list, options)

0
spa/api/v1/__init__.py Normal file → Executable file
View File

0
spa/api/v1/tests.py Normal file → Executable file
View File

0
spa/audio.py Normal file → Executable file
View File

0
spa/context_processors.py Normal file → Executable file
View File

0
spa/forms.py Normal file → Executable file
View File

0
spa/management/__init__.py Normal file → Executable file
View File

0
spa/management/commands/__init__.py Normal file → Executable file
View File

0
spa/management/commands/__template_Debug.py Normal file → Executable file
View File

0
spa/management/commands/debugHumanize.py Normal file → Executable file
View File

0
spa/management/commands/debugUserProfile.py Normal file → Executable file
View File

0
spa/management/commands/deletefailed.py Normal file → Executable file
View File

0
spa/management/commands/deleteorphanmp3.py Normal file → Executable file
View File

0
spa/management/commands/drop.py Normal file → Executable file
View File

0
spa/management/commands/importdownloads.py Normal file → Executable file
View File

0
spa/management/commands/importplays.py Normal file → Executable file
View File

0
spa/management/commands/processmix.py Normal file → Executable file
View File

0
spa/management/commands/processuser.py Normal file → Executable file
View File

0
spa/management/commands/purchaselinks.py Normal file → Executable file
View File

0
spa/management/commands/tracklists.py Normal file → Executable file
View File

0
spa/management/commands/waveforms.py Normal file → Executable file
View File

0
spa/middleware/__init__.py Normal file → Executable file
View File

0
spa/middleware/sqlprinter.py Normal file → Executable file
View File

0
spa/middleware/stripwhitespace.py Normal file → Executable file
View File

0
spa/middleware/uploadify.py Normal file → Executable file
View File

0
spa/migrations/0001_initial.py Normal file → Executable file
View File

0
spa/migrations/0002_auto__add_userfollows.py Normal file → Executable file
View File

0
spa/migrations/0003_auto__add_field_mix_duration.py Normal file → Executable file
View File

0
spa/migrations/0004_auto__add_field_mix_slug.py Normal file → Executable file
View File

View File

0
spa/migrations/0006_auto__chg_field_mix_title.py Normal file → Executable file
View File

View File

View File

0
spa/migrations/0010_auto.py Normal file → Executable file
View File

0
spa/migrations/0011_auto__del_field__activity_user.py Normal file → Executable file
View File

0
spa/migrations/0012_auto__add_field__activity_user.py Normal file → Executable file
View File

View File

View File

View File

0
spa/migrations/0016_auto__del_mixlike.py Normal file → Executable file
View File

0
spa/migrations/0017_auto__add_mixlike.py Normal file → Executable file
View File

0
spa/migrations/0019_auto__add_activityfavourite.py Normal file → Executable file
View File

0
spa/migrations/0020_auto__add_activityplay.py Normal file → Executable file
View File

0
spa/migrations/0021_auto__add_activitylike.py Normal file → Executable file
View File

0
spa/migrations/0022_auto__add_activitydownload.py Normal file → Executable file
View File

0
spa/migrations/__init__.py Normal file → Executable file
View File

0
spa/models/__init__.py Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More