diff --git a/api/views.py b/api/views.py index 7001e4f..d89eb27 100755 --- a/api/views.py +++ b/api/views.py @@ -153,7 +153,7 @@ class SearchResultsView(views.APIView): if q_type == 'user': r_s = [ { - 'title': user.display_name, + 'title': user.get_nice_name(), 'image': user.get_sized_avatar_image(64, 64), 'slug': user.slug, 'url': user.get_absolute_url(), @@ -161,7 +161,7 @@ class SearchResultsView(views.APIView): } for user in UserProfile.objects.filter( Q(user__first_name__icontains=q) | Q(user__last_name__icontains=q) | - Q(display_name__icontains=q))[0:10] + Q(display_name__icontains=q)).exclude(slug__isnull=True).exclude(slug__exact='')[0:10] ] else: r_s = [{ @@ -178,13 +178,17 @@ class SearchResultsView(views.APIView): class PartialMixUploadView(views.APIView): parser_classes = (FileUploadParser,) - permission_classes = (IsAuthenticated,) + # TODO have to make this anonymous (for now) because dropzone doesn't play nice with JWT + #permission_classes = (IsAuthenticated,) # noinspection PyBroadException def post(self, request): try: logger.info("Received post file") uid = request.META.get('HTTP_UPLOAD_HASH') + session_id = request.META.get('HTTP_SESSION_ID') + logger.info("Session Id: {0}".format(session_id)) + in_file = request.data['file'] if request.data else None file_name, extension = os.path.splitext(in_file.name) @@ -212,7 +216,7 @@ class PartialMixUploadView(views.APIView): tasks.create_waveform_task.s(input_file, uid) | tasks.upload_to_cdn_task.subtask(('mp3', uid, 'mixes'), immutable=True) | tasks.upload_to_cdn_task.subtask(('png', uid, 'waveforms'), immutable=True) | - tasks.notify_subscriber.subtask((request.user.userprofile.get_session_id(), uid), immutable=True) + tasks.notify_subscriber.subtask((session_id, uid), immutable=True) ).delay() logger.debug("Waveform task started") @@ -274,7 +278,7 @@ class NotificationViewSet(viewsets.ModelViewSet): if not user.is_authenticated(): raise PermissionDenied("Not allowed") - return Notification.objects.filter(to_user=user.userprofile).order_by('-date') + return Notification.objects.filter(to_user=user.userprofile).order_by('-id') def perform_update(self, serializer): return super(NotificationViewSet, self).perform_update(serializer) diff --git a/dss/settings.py b/dss/settings.py index e003c7c..7e5abf2 100755 --- a/dss/settings.py +++ b/dss/settings.py @@ -70,7 +70,6 @@ TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + ( 'django.contrib.auth.context_processors.auth', ) - MIDDLEWARE_CLASSES = ( 'django.middleware.gzip.GZipMiddleware', 'django.middleware.common.CommonMiddleware', @@ -84,7 +83,7 @@ MIDDLEWARE_CLASSES = ( # 'htmlmin.middleware.MarkRequestMiddleware', 'django_user_agents.middleware.UserAgentMiddleware', # 'spa.middleware.uploadify.SWFUploadMiddleware', - # 'spa.middleware.sqlprinter.SqlPrintingMiddleware' if DEBUG else None, + # 'spa.middleware.sqlprinter.SqlPrintingMiddleware', # 'debug_toolbar.middleware.DebugToolbarMiddleware', ) @@ -101,11 +100,11 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admindocs', - #'django_facebook', + # 'django_facebook', 'django_extensions', 'django_gravatar', - # TODO: remove + # TODO: remove 'allauth', 'allauth.account', 'allauth.socialaccount', @@ -124,8 +123,6 @@ INSTALLED_APPS = ( 'storages', 'social.apps.django_app.default', - - 'dbbackup', 'djrill', 'rest_framework', @@ -138,7 +135,6 @@ LOGOUT_URL = reverse_lazy('home') FACEBOOK_APP_ID = '154504534677009' - AVATAR_STORAGE_DIR = MEDIA_ROOT + '/avatars/' ACCOUNT_LOGOUT_REDIRECT_URL = '/' @@ -150,7 +146,7 @@ TASTYPIE_ALLOW_MISSING_SLASH = True SENDFILE_ROOT = os.path.join(MEDIA_ROOT, 'mixes') SENDFILE_URL = '/media/mixes' -#SESSION_ENGINE = 'django.contrib.sessions.models.Session' +# SESSION_ENGINE = 'django.contrib.sessions.models.Session' mimetypes.add_type("text/xml", ".plist", False) @@ -213,6 +209,7 @@ THUMBNAIL_PREFIX = '_tn/' JWT_AUTH = { 'JWT_EXPIRATION_DELTA': timedelta(seconds=900), + # 'JWT_EXPIRATION_DELTA': timedelta(seconds=5), 'JWT_ALLOW_REFRESH': True, 'JWT_REFRESH_EXPIRATION_DELTA': timedelta(days=30), } diff --git a/spa/models/message.py b/spa/models/message.py index f5f7cee..bb4806d 100644 --- a/spa/models/message.py +++ b/spa/models/message.py @@ -29,7 +29,8 @@ class Message(BaseModel): body = models.TextField() - def create_notification(self, accept=False): + # TODO: Need to keep this away from normal notifications + def __create_notification(self, accept=False): try: notification = Notification() notification.from_user = self.from_user diff --git a/spa/models/notification.py b/spa/models/notification.py index b15289f..e782a30 100755 --- a/spa/models/notification.py +++ b/spa/models/notification.py @@ -39,7 +39,7 @@ class Notification(BaseModel): 'user:message', self.to_user.get_session_id(), { - 'from_user': self.from_user.slug, + 'from_user': self.from_user.slug if self.from_user is not None else settings.DEFAULT_USER_NAME, 'message': self.target_desc })