diff --git a/api/auth.py b/api/auth.py index 77d5445..ad9b373 100644 --- a/api/auth.py +++ b/api/auth.py @@ -188,6 +188,7 @@ class ObtainUser(APIView): status=status.HTTP_200_OK, data={ 'id': request.user.id, 'name': request.user.username, + 'session': request.user.userprofile.get_session_id(), 'slug': request.user.userprofile.slug, 'userRole': 'user' }) diff --git a/api/urls.py b/api/urls.py index bbeebc1..d438afd 100755 --- a/api/urls.py +++ b/api/urls.py @@ -28,8 +28,8 @@ router.register(r'playlist', views.PlaylistViewSet, base_name='playlists') class DebugView(APIView): - permission_classes = (IsAuthenticated,) - authentication_classes = (JSONWebTokenAuthentication,) + #permission_classes = (IsAuthenticated,) + #authentication_classes = (JSONWebTokenAuthentication,) def get(self, request): print(self.request.session) @@ -39,14 +39,16 @@ class DebugView(APIView): def post(self, request, format=None): try: activity.post_activity( - channel='user:message', + channel='user:broadcast', message='Hello Sailor', - session=request.user.userprofile.get_session_id()) + session=2, + # session=request.user.userprofile.get_session_id(), + ) except Exception as ex: print(ex) return Response({ - 'status': request.user.first_name, + 'status': 'Hello', 'message': 'Sailor' }, status=status.HTTP_200_OK) diff --git a/db_reset b/db_reset new file mode 100755 index 0000000..65a91c4 --- /dev/null +++ b/db_reset @@ -0,0 +1,5 @@ +sudo -u postgres dropdb deepsouthsounds +sudo -u postgres createdb deepsouthsounds --owner deepsouthsounds + +sudo -u postgres psql deepsouthsounds < /mnt/dev/backup.sql + diff --git a/dss/storagesettings.py b/dss/storagesettings.py index d37f9e1..f96f011 100644 --- a/dss/storagesettings.py +++ b/dss/storagesettings.py @@ -1,7 +1,8 @@ from dss import localsettings import os -AZURE_ACCOUNT_NAME = os.environ.get('CDN_NAME', 'dsscdn') +DEBUG_AZURE_ACCOUNT_NAME = os.environ.get('CDN_NAME', 'dsscdn') +AZURE_ACCOUNT_NAME = os.environ.get('CDN_NAME', 'dsscdn2') AZURE_CONTAINER = 'media' AZURE_ACCOUNT_KEY = localsettings.AZURE_ACCOUNT_KEY AZURE_ITEM_BASE_URL = 'https://{}.blob.core.windows.net/'.format(AZURE_ACCOUNT_NAME) diff --git a/spa/models/activity.py b/spa/models/activity.py index ed8baf7..74e89e3 100755 --- a/spa/models/activity.py +++ b/spa/models/activity.py @@ -6,6 +6,7 @@ from django.db import models from model_utils.managers import InheritanceManager from open_facebook import OpenFacebook +from core.realtime import activity as realtime from core.utils.url import wrap_full from dss import settings from spa.models.notification import Notification @@ -61,6 +62,18 @@ class Activity(BaseModel): print(ex) pass + def post_broadcast(self): + try: + display_name = self.user.display_name if self.user is not None else 'Anonymous' + notice = "{} {} {}".format( + display_name, + self.get_verb_past(), + self.get_object_name()) + target_user = self.get_target_user() + realtime.post_activity('user:broadcast', notice, target_user.get_session_id()) + except Exception as ex: + pass + def create_notification(self, accept=False): try: notification = Notification() diff --git a/spa/models/notification.py b/spa/models/notification.py index 7ea116f..8d1c95e 100755 --- a/spa/models/notification.py +++ b/spa/models/notification.py @@ -27,18 +27,6 @@ class Notification(BaseModel): def get_notification_url(self): return '/api/v1/notification/%s' % self.id - def save(self, force_insert=False, force_update=False, using=None, - update_fields=None): - post_activity( - channel='user:message', - message={ - 'from_user': self.from_user.slug if self.from_user is not None else settings.DEFAULT_USER_NAME, - 'message': self.target_desc - }, - session=self.to_user.get_session_id(), - ) - return super(Notification, self).save(force_insert, force_update, using, update_fields) - def send_notification_email(self): try: if settings.DEBUG: diff --git a/spa/signals.py b/spa/signals.py index 2756d6c..0a209a2 100755 --- a/spa/signals.py +++ b/spa/signals.py @@ -94,6 +94,8 @@ def post_save_handler(**kwargs): # should save post to the activity feed if hasattr(instance, 'create_activity'): instance.create_activity() + if hasattr(instance, 'post_broadcast'): + instance.post_broadcast() # try to get the user's geo profile if hasattr(instance, 'update_geo_info'):