mirror of
https://github.com/fergalmoran/dss.git
synced 2026-01-08 18:06:10 +00:00
First draft user profile sidebar
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
## Django settings for dss project.
|
||||
#e Django settings for dss project.
|
||||
from datetime import timedelta
|
||||
import os
|
||||
|
||||
@@ -44,9 +44,9 @@ USE_L10N = True
|
||||
USE_TZ = True
|
||||
|
||||
SITE_ROOT = here('')
|
||||
MEDIA_ROOT = here('media')
|
||||
MEDIA_ROOT = here('../media')
|
||||
STATIC_ROOT = here('static') #localsettings.STATIC_ROOT if hasattr(localsettings, 'STATIC_ROOT') else ''
|
||||
CACHE_ROOT = here('media/cache')
|
||||
CACHE_ROOT = here('../media/cache')
|
||||
|
||||
if DEBUG:
|
||||
STATIC_URL = '/static/'
|
||||
@@ -133,8 +133,8 @@ MIDDLEWARE_CLASSES = (
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'spa.middleware.uploadify.SWFUploadMiddleware',
|
||||
'spa.middleware.sqlprinter.SqlPrintingMiddleware',
|
||||
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||
#'spa.middleware.sqlprinter.SqlPrintingMiddleware',
|
||||
#'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||
)
|
||||
|
||||
WSGI_APPLICATION = 'dss.wsgi.application'
|
||||
|
||||
@@ -4,6 +4,7 @@ from tastypie.authentication import Authentication
|
||||
from tastypie.authorization import DjangoAuthorization
|
||||
from spa.api.v1.BackboneCompatibleResource import BackboneCompatibleResource
|
||||
from spa.models import UserProfile
|
||||
from django.conf.urls import url
|
||||
|
||||
|
||||
class UserProfileResource(BackboneCompatibleResource):
|
||||
@@ -19,7 +20,6 @@ class UserProfileResource(BackboneCompatibleResource):
|
||||
def _hydrateBitmapOption(self, source, comparator):
|
||||
return "checked" if (source & comparator) != 0 else ""
|
||||
|
||||
|
||||
def hydrate(self, bundle):
|
||||
if 'activity_sharing_likes' in bundle.data:
|
||||
likes = UserProfile.ACTIVITY_SHARE_LIKES if bundle.data['activity_sharing_likes'] else 0
|
||||
@@ -55,6 +55,8 @@ class UserProfileResource(BackboneCompatibleResource):
|
||||
def dehydrate(self, bundle):
|
||||
del bundle.data['activity_sharing']
|
||||
del bundle.data['activity_sharing_networks']
|
||||
bundle.data['display_name'] = bundle.obj.get_nice_name()
|
||||
bundle.data['avatar_image'] = bundle.obj.get_avatar_image()
|
||||
if bundle.obj.user.id == bundle.request.user.id:
|
||||
bundle.data['activity_sharing_likes'] = \
|
||||
self._hydrateBitmapOption(bundle.obj.activity_sharing, UserProfile.ACTIVITY_SHARE_LIKES)
|
||||
@@ -80,6 +82,12 @@ class UserResource(BackboneCompatibleResource):
|
||||
authorization = DjangoAuthorization()
|
||||
authentication = Authentication()
|
||||
|
||||
def prepend_urls(self):
|
||||
return [
|
||||
url(r"^(?P<resource_name>%s)/(?P<pk>\d+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
|
||||
url(r"^(?P<resource_name>%s)/(?P<userprofile__slug>[\w\d_.-]+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
|
||||
]
|
||||
|
||||
def dehydrate(self, bundle):
|
||||
if bundle.obj.id != bundle.request.user.id:
|
||||
del bundle.data['email']
|
||||
|
||||
BIN
static/img/toolbar-loader.gif
Normal file
BIN
static/img/toolbar-loader.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -9,6 +9,7 @@
|
||||
var AppRouter = Backbone.Router.extend({
|
||||
root: '/',
|
||||
routes: {
|
||||
"debug": "debug",
|
||||
"mixes": "mixList",
|
||||
"mixes/:type": "mixList",
|
||||
"mix/upload": "mixUpload",
|
||||
@@ -52,15 +53,46 @@ var AppRouter = Backbone.Router.extend({
|
||||
|
||||
}
|
||||
},
|
||||
debug: function () {
|
||||
var model = new User({
|
||||
id: 'fergal'
|
||||
});
|
||||
model.fetch({
|
||||
success: function(){
|
||||
var content= new SidebarViewUser({
|
||||
model: model
|
||||
});
|
||||
$('#content').html(content.render().el);
|
||||
}
|
||||
});
|
||||
},
|
||||
user: function (user) {
|
||||
this._renderMixList('latest', { "user": user });
|
||||
var model = new User({
|
||||
id: user
|
||||
});
|
||||
this.sidebarView = new SidebarViewUser({
|
||||
model: model
|
||||
model.fetch({
|
||||
success: function(){
|
||||
var content= new SidebarViewUser({
|
||||
model: model
|
||||
});
|
||||
$('#sidebar').html(content.render().el);
|
||||
}
|
||||
});
|
||||
},
|
||||
userDetails: function () {
|
||||
var user = new User({
|
||||
id: com.podnoms.settings.currentUser
|
||||
});
|
||||
$('#site-content-fill').html('');
|
||||
user.fetch({
|
||||
success: function () {
|
||||
var content = new UserView({
|
||||
model: user
|
||||
});
|
||||
$('#content').html(content.render().el);
|
||||
}
|
||||
});
|
||||
$('#sidebar').html(this.sidebarView.el);
|
||||
},
|
||||
mixList: function (type) {
|
||||
this._renderMixList(type);
|
||||
@@ -84,8 +116,7 @@ var AppRouter = Backbone.Router.extend({
|
||||
var mixes = new MixListView({
|
||||
collection: mixList
|
||||
});
|
||||
var content = mixes.el;
|
||||
$('#content').html(content);
|
||||
$('#content').html(mixes.el);
|
||||
if (mixes.itemPlaying != null) {
|
||||
com.podnoms.settings.setupPlayer(mixes.itemPlaying.toJSON(), mixes.itemPlaying.get('id'));
|
||||
}
|
||||
@@ -119,7 +150,7 @@ var AppRouter = Backbone.Router.extend({
|
||||
},
|
||||
mixEdit: function (id) {
|
||||
var mix = new Mix({
|
||||
id: id
|
||||
slug: id
|
||||
});
|
||||
mix.fetch({
|
||||
success: function () {
|
||||
@@ -219,20 +250,6 @@ var AppRouter = Backbone.Router.extend({
|
||||
},
|
||||
connectAccounts: function () {
|
||||
alert("Connecting accounts");
|
||||
},
|
||||
userDetails: function () {
|
||||
var user = new User({
|
||||
id: com.podnoms.settings.currentUser
|
||||
});
|
||||
$('#site-content-fill').html('');
|
||||
user.fetch({
|
||||
success: function () {
|
||||
var content = new UserView({
|
||||
model: user
|
||||
});
|
||||
$('#content').html(content.render().el);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
$('#ajax-request').hide();
|
||||
if (window.location.hash == '#_=_') {
|
||||
window.location.hash = "";
|
||||
}
|
||||
@@ -14,7 +15,14 @@ $(document).ready(function () {
|
||||
Backbone.history.navigate("/");
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on({
|
||||
ajaxStart: function () {
|
||||
$('#ajax-request').show();
|
||||
},
|
||||
ajaxStop: function () {
|
||||
$('#ajax-request').hide();
|
||||
}
|
||||
});
|
||||
$(document).ajaxSend(function (event, xhr, settings) {
|
||||
function getCookie(name) {
|
||||
var cookieValue = null;
|
||||
|
||||
@@ -23,15 +23,6 @@ window.HeaderView = Backbone.View.extend({
|
||||
},
|
||||
login: function () {
|
||||
com.podnoms.utils.modal('tpl/LoginView');
|
||||
return;
|
||||
$.colorbox({
|
||||
href: "/tpl/LoginView/",
|
||||
onClosed: function () {
|
||||
Backbone.history.navigate('/', {
|
||||
trigger: true
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
logout: function () {
|
||||
com.podnoms.utils.showAlert("Success", "You are now logged out");
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
window.SidebarViewUser = Backbone.View.extend({
|
||||
events: {
|
||||
},
|
||||
initialize: function () {
|
||||
this.render();
|
||||
},
|
||||
render: function () {
|
||||
$(this.el).html(this.template({"item":this.model.toJSON()}));
|
||||
ich.addTemplate('sidebaruser', this.template());
|
||||
var rendered = ich.sidebaruser(this.model.toJSON());
|
||||
$(this.el).html(rendered);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,8 +12,6 @@ UserView = DSSEditableView.extend({
|
||||
"click #save-changes": "saveChanges",
|
||||
"change input[type=radio]": "selectAvatar"
|
||||
},
|
||||
initialize: function () {
|
||||
},
|
||||
render: function () {
|
||||
ich.addTemplate('user', this.template());
|
||||
var renderedTemplate = ich.user(this.model.toJSON());
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
{% load spa_extras %}
|
||||
<div class="navbar navbar-fixed-top navbar-inverse" xmlns="http://www.w3.org/1999/html">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<div class="container-fluid">
|
||||
<a href="/" class="brand">
|
||||
<img src="{{ STATIC_URL }}img/site-logo-gr.png"/>
|
||||
<img id="ajax-request" class="pull-left" src="{{ STATIC_URL }}img/toolbar-loader.gif"/>
|
||||
Deep|South|Sounds</a>
|
||||
|
||||
<div class="nav-collapse">
|
||||
@@ -14,16 +14,20 @@
|
||||
<li><a href="/events">Events</a></li>
|
||||
{% if user.is_authenticated %}
|
||||
<li>
|
||||
<form id="logout-form" method="post" action="{% url "account_logout" %}" style="display: none">
|
||||
<form id="logout-form" method="post" action="{% url "account_logout" %}"
|
||||
style="display: none">
|
||||
{% csrf_token %}
|
||||
</form>
|
||||
<a data-bypass="true" style="cursor: hand; cursor: pointer;" id="header-logout-button" onclick="document.getElementById('logout-form').submit();">Logout <i class="icon-eject icon-white"></i>
|
||||
<a data-bypass="true" style="cursor: hand; cursor: pointer;" id="header-logout-button"
|
||||
onclick="document.getElementById('logout-form').submit();">Logout <i
|
||||
class="icon-eject icon-white"></i>
|
||||
</a>
|
||||
<input type="hidden" name="user_id" value="{{ user.id }}" />
|
||||
<input type="hidden" name="user_id" value="{{ user.id }}"/>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<a data-bypass="true" id="header-login-button">Login/Signup <i class="icon-music icon-white"></i></a>
|
||||
<a data-bypass="true" id="header-login-button">Login/Signup <i
|
||||
class="icon-music icon-white"></i></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<div>
|
||||
<h1>Hello Sailor</h1>
|
||||
<%= item.display_name %>
|
||||
</div>
|
||||
{% verbatim %}
|
||||
<div>
|
||||
<h5>{{ profile.display_name }}</h5>
|
||||
<img src="{{ profile.avatar_image }}" class="img-polaroid">
|
||||
<p>{{ profile.description }}</p>
|
||||
</div>
|
||||
{% endverbatim %}
|
||||
|
||||
Reference in New Issue
Block a user