mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-22 09:38:18 +00:00
Merge settings
This commit is contained in:
10
api/serialisers.py
Normal file
10
api/serialisers.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from rest_framework import serializers
|
||||
from spa.models.comment import Comment
|
||||
|
||||
|
||||
class CommentSerialiser(serializers.HyperlinkedModelSerializer):
|
||||
user = serializers.RelatedField(many=False)
|
||||
|
||||
class Meta:
|
||||
model = Comment
|
||||
fields = ('comment', 'date_created', 'user')
|
||||
12
api/urls.py
Normal file
12
api/urls.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from api.views import CommentViewSet
|
||||
from django.conf.urls import url, patterns, include
|
||||
from rest_framework import routers
|
||||
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'comments', CommentViewSet)
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^', include(router.urls)),
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
#e Django settings for dss project.
|
||||
# e Django settings for dss project.
|
||||
import os
|
||||
import mimetypes
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
@@ -35,7 +35,8 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
import sys
|
||||
if 'test' in sys.argv or 'test_coverage' in sys.argv: #Covers regular testing and django-coverage
|
||||
|
||||
if 'test' in sys.argv or 'test_coverage' in sys.argv: # Covers regular testing and django-coverage
|
||||
print "Testing"
|
||||
DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
|
||||
|
||||
@@ -89,11 +90,11 @@ MIDDLEWARE_CLASSES = (
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'spa.middleware.cors.XsSharingMiddleware',
|
||||
#'htmlmin.middleware.HtmlMinifyMiddleware',
|
||||
# 'htmlmin.middleware.HtmlMinifyMiddleware',
|
||||
#'htmlmin.middleware.MarkRequestMiddleware',
|
||||
'django_user_agents.middleware.UserAgentMiddleware',
|
||||
'pipeline.middleware.MinifyHTMLMiddleware',
|
||||
#'spa.middleware.uploadify.SWFUploadMiddleware',
|
||||
# 'spa.middleware.uploadify.SWFUploadMiddleware',
|
||||
#'spa.middleware.sqlprinter.SqlPrintingMiddleware' if DEBUG else None,
|
||||
#'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||
)
|
||||
@@ -138,8 +139,9 @@ INSTALLED_APPS = (
|
||||
'djrill',
|
||||
'paypal.standard.ipn',
|
||||
'django_user_agents',
|
||||
'storages',
|
||||
#'backbone_tastypie',
|
||||
'storages',
|
||||
'rest_framework',
|
||||
# 'backbone_tastypie',
|
||||
)
|
||||
|
||||
# where to redirect users to after logging in
|
||||
@@ -181,11 +183,9 @@ mimetypes.add_type("text/xml", ".plist", False)
|
||||
|
||||
HTML_MINIFY = not DEBUG
|
||||
|
||||
|
||||
DEFAULT_FROM_EMAIL = 'DSS ChatBot <chatbot@deepsouthsounds.com>'
|
||||
DEFAULT_HTTP_PROTOCOL = 'http'
|
||||
|
||||
|
||||
EMAIL_BACKEND = 'djrill.mail.backends.djrill.DjrillBackend'
|
||||
|
||||
if DEBUG:
|
||||
@@ -208,3 +208,15 @@ if 'test' in sys.argv:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
# Use hyperlinked styles by default.
|
||||
# Only used if the `serializer_class` attribute is not set on a view.
|
||||
'DEFAULT_MODEL_SERIALIZER_CLASS':
|
||||
'rest_framework.serializers.HyperlinkedModelSerializer',
|
||||
|
||||
# Use Django's standard `django.contrib.auth` permissions,
|
||||
# or allow read-only access for unauthenticated users.
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
||||
]
|
||||
}
|
||||
@@ -14,6 +14,8 @@ urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^favicon\.ico$', RedirectView.as_view(url='/static/img/favicon.ico')),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^api/v2/', include('api.urls', namespace='api_v2')),
|
||||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
||||
url(r'', include('user_sessions.urls', 'user_sessions')),
|
||||
(r'^channel\.html$', TemplateView.as_view(template_name='boiler/fb_channel.html')),
|
||||
(r'^privacy\.html$', TemplateView.as_view(template_name='boiler/privacy.html')),
|
||||
|
||||
@@ -11,6 +11,9 @@ from spa.models.comment import Comment
|
||||
|
||||
class CommentResource(BackboneCompatibleResource):
|
||||
mix = fields.ToOneField('spa.api.v1.MixResource.MixResource', 'mix')
|
||||
likes = fields.ToManyField('spa.api.v1.UserResource.UserResource',
|
||||
'likes', related_name='favourites',
|
||||
full=False, null=True)
|
||||
|
||||
class Meta:
|
||||
queryset = Comment.objects.all().order_by('-date_created')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
||||
from spa.models import BaseModel
|
||||
from spa.models import BaseModel, UserProfile
|
||||
from spa.models.mix import Mix
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ class Comment(BaseModel):
|
||||
comment = models.CharField(max_length=1024)
|
||||
date_created = models.DateTimeField(auto_now_add=True)
|
||||
time_index = models.IntegerField(default=0)
|
||||
likes = models.ManyToManyField(UserProfile, related_name='liked_comments', blank=True, null=True)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return '/comment/%i' % self.id
|
||||
|
||||
@@ -79,6 +79,11 @@
|
||||
no: ->
|
||||
console.log("Controller: mixDeleteNO!!")
|
||||
|
||||
@listenTo @vent, "comment:like", (model, id, success, favourite) ->
|
||||
console.log "App(vent): mix:like"
|
||||
model.save 'liked', !model.get('liked'), patch: true
|
||||
true
|
||||
|
||||
@listenTo @vent, "user:follow", (model)->
|
||||
console.log "App(vent): user:follow"
|
||||
user = new App.UserApp.Models.UserItem({id: com.podnoms.settings.currentUser })
|
||||
|
||||
@@ -3,8 +3,13 @@
|
||||
template: "commentitemview"
|
||||
events:
|
||||
"click #delete-comment": "deleteComment"
|
||||
"click #like-comment": "likeComment"
|
||||
|
||||
deleteComment: ->
|
||||
utils.messageBox "/dlg/DeleteCommentConfirm", =>
|
||||
@model.destroy()
|
||||
|
||||
likeComment: ->
|
||||
console.log("CommentItemView: likeComment")
|
||||
App.vent.trigger("comment:like", @model)
|
||||
true
|
||||
|
||||
@@ -13,13 +13,17 @@
|
||||
<a href="<%= user_url %>"><%= user_name %></a>
|
||||
</div>
|
||||
<div class="text"><%= comment %></div>
|
||||
|
||||
<% if (can_edit) { %>
|
||||
<div class="tools">
|
||||
<a id="delete-comment" class="btn btn-minier btn-danger">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
<% if (utils.isAuth()) { %>
|
||||
<div class="tools">
|
||||
<a id="like-comment" class="btn btn-xs btn-primary">
|
||||
<i class="fa fa-thumbs-o-up"></i>
|
||||
</a>
|
||||
<% if (can_edit) { %>
|
||||
<a id="delete-comment" class="btn btn-xs btn-danger">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user