mirror of
https://github.com/fergalmoran/dss.api.git
synced 2025-12-22 17:28:55 +00:00
Fixed realtime ('ish)
This commit is contained in:
@@ -188,6 +188,7 @@ class ObtainUser(APIView):
|
|||||||
status=status.HTTP_200_OK, data={
|
status=status.HTTP_200_OK, data={
|
||||||
'id': request.user.id,
|
'id': request.user.id,
|
||||||
'name': request.user.username,
|
'name': request.user.username,
|
||||||
|
'session': request.user.userprofile.get_session_id(),
|
||||||
'slug': request.user.userprofile.slug,
|
'slug': request.user.userprofile.slug,
|
||||||
'userRole': 'user'
|
'userRole': 'user'
|
||||||
})
|
})
|
||||||
|
|||||||
12
api/urls.py
12
api/urls.py
@@ -28,8 +28,8 @@ router.register(r'playlist', views.PlaylistViewSet, base_name='playlists')
|
|||||||
|
|
||||||
|
|
||||||
class DebugView(APIView):
|
class DebugView(APIView):
|
||||||
permission_classes = (IsAuthenticated,)
|
#permission_classes = (IsAuthenticated,)
|
||||||
authentication_classes = (JSONWebTokenAuthentication,)
|
#authentication_classes = (JSONWebTokenAuthentication,)
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
print(self.request.session)
|
print(self.request.session)
|
||||||
@@ -39,14 +39,16 @@ class DebugView(APIView):
|
|||||||
def post(self, request, format=None):
|
def post(self, request, format=None):
|
||||||
try:
|
try:
|
||||||
activity.post_activity(
|
activity.post_activity(
|
||||||
channel='user:message',
|
channel='user:broadcast',
|
||||||
message='Hello Sailor',
|
message='Hello Sailor',
|
||||||
session=request.user.userprofile.get_session_id())
|
session=2,
|
||||||
|
# session=request.user.userprofile.get_session_id(),
|
||||||
|
)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(ex)
|
print(ex)
|
||||||
|
|
||||||
return Response({
|
return Response({
|
||||||
'status': request.user.first_name,
|
'status': 'Hello',
|
||||||
'message': 'Sailor'
|
'message': 'Sailor'
|
||||||
}, status=status.HTTP_200_OK)
|
}, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
|
|||||||
5
db_reset
Executable file
5
db_reset
Executable file
@@ -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
|
||||||
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
from dss import localsettings
|
from dss import localsettings
|
||||||
import os
|
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_CONTAINER = 'media'
|
||||||
AZURE_ACCOUNT_KEY = localsettings.AZURE_ACCOUNT_KEY
|
AZURE_ACCOUNT_KEY = localsettings.AZURE_ACCOUNT_KEY
|
||||||
AZURE_ITEM_BASE_URL = 'https://{}.blob.core.windows.net/'.format(AZURE_ACCOUNT_NAME)
|
AZURE_ITEM_BASE_URL = 'https://{}.blob.core.windows.net/'.format(AZURE_ACCOUNT_NAME)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from django.db import models
|
|||||||
from model_utils.managers import InheritanceManager
|
from model_utils.managers import InheritanceManager
|
||||||
from open_facebook import OpenFacebook
|
from open_facebook import OpenFacebook
|
||||||
|
|
||||||
|
from core.realtime import activity as realtime
|
||||||
from core.utils.url import wrap_full
|
from core.utils.url import wrap_full
|
||||||
from dss import settings
|
from dss import settings
|
||||||
from spa.models.notification import Notification
|
from spa.models.notification import Notification
|
||||||
@@ -61,6 +62,18 @@ class Activity(BaseModel):
|
|||||||
print(ex)
|
print(ex)
|
||||||
pass
|
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):
|
def create_notification(self, accept=False):
|
||||||
try:
|
try:
|
||||||
notification = Notification()
|
notification = Notification()
|
||||||
|
|||||||
@@ -27,18 +27,6 @@ class Notification(BaseModel):
|
|||||||
def get_notification_url(self):
|
def get_notification_url(self):
|
||||||
return '/api/v1/notification/%s' % self.id
|
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):
|
def send_notification_email(self):
|
||||||
try:
|
try:
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ def post_save_handler(**kwargs):
|
|||||||
# should save post to the activity feed
|
# should save post to the activity feed
|
||||||
if hasattr(instance, 'create_activity'):
|
if hasattr(instance, 'create_activity'):
|
||||||
instance.create_activity()
|
instance.create_activity()
|
||||||
|
if hasattr(instance, 'post_broadcast'):
|
||||||
|
instance.post_broadcast()
|
||||||
|
|
||||||
# try to get the user's geo profile
|
# try to get the user's geo profile
|
||||||
if hasattr(instance, 'update_geo_info'):
|
if hasattr(instance, 'update_geo_info'):
|
||||||
|
|||||||
Reference in New Issue
Block a user