Rudimentary donations system

This commit is contained in:
Fergal Moran
2013-10-03 21:02:48 +01:00
parent 5bc44c189b
commit 3b4bd33e2a
9 changed files with 63 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ import os
import logging
from django.conf.urls import url
from django.http import Http404, HttpResponse
from django.http import Http404, HttpResponse, HttpResponseForbidden, HttpResponseNotFound
from django.core.servers.basehttp import FileWrapper
from sendfile import sendfile
@@ -28,6 +28,9 @@ class AudioHandler(object):
def download(request, mix_id):
try:
if not request.user.is_authenticated():
return HttpResponseForbidden("Get tae fuck!!!")
mix = Mix.objects.get(pk=mix_id)
if mix is not None:
if mix.download_allowed:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -50,6 +50,11 @@ define ['backbone', 'marionette', 'vent', 'utils',
utils.modal "/dlg/LoginView"
true
@listenTo vent, "app:donate", ->
console.log("App: donate")
utils.modal "/dlg/Donate"
true
@listenTo vent, "mix:favourite", (model) ->
console.log "App(vent): mix:favourite"
model.save 'favourited', !model.get('favourited'), patch: true

View File

@@ -52,6 +52,11 @@
utils.modal("/dlg/LoginView");
return true;
});
this.listenTo(vent, "app:donate", function() {
console.log("App: donate");
utils.modal("/dlg/Donate");
return true;
});
this.listenTo(vent, "mix:favourite", function(model) {
console.log("App(vent): mix:favourite");
model.save('favourited', !model.get('favourited'), {

View File

@@ -18,6 +18,7 @@ define ["underscore", "marionette", "vent", "utils", "views/widgets/searchView",
events:
"click #header-play-pause-button": "togglePlayState"
"click #header-login-button": "login"
"click #header-donate-button": "donate"
"click #header-live-button.btn-success": "playLive"
"click #header-live-button.btn-danger": "pauseLive"
ui:
@@ -42,6 +43,10 @@ define ["underscore", "marionette", "vent", "utils", "views/widgets/searchView",
login: ->
vent.trigger('app:login')
donate: ->
console.log("headerView: donate")
vent.trigger('app:donate')
logout: ->
utils.showAlert "Success", "You are now logged out"

View File

@@ -1,4 +1,5 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.4.0
/*
@license
@@ -14,16 +15,14 @@ Code provided under the BSD License:
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
define(["underscore", "marionette", "vent", "utils", "views/widgets/searchView", "views/notifications/notificationsListView", "text!/tpl/HeaderView"], function(_, Marionette, vent, utils, SearchView, NotificationsListView, Template) {
var HeaderView, _ref;
var HeaderView;
HeaderView = (function(_super) {
var NowrapRegion;
__extends(HeaderView, _super);
function HeaderView() {
_ref = HeaderView.__super__.constructor.apply(this, arguments);
return _ref;
return HeaderView.__super__.constructor.apply(this, arguments);
}
NowrapRegion = Marionette.Region.extend({
@@ -39,6 +38,7 @@ Code provided under the BSD License:
HeaderView.prototype.events = {
"click #header-play-pause-button": "togglePlayState",
"click #header-login-button": "login",
"click #header-donate-button": "donate",
"click #header-live-button.btn-success": "playLive",
"click #header-live-button.btn-danger": "pauseLive"
};
@@ -71,6 +71,11 @@ Code provided under the BSD License:
return vent.trigger('app:login');
};
HeaderView.prototype.donate = function() {
console.log("headerView: donate");
return vent.trigger('app:donate');
};
HeaderView.prototype.logout = function() {
return utils.showAlert("Success", "You are now logged out");
};

View File

View File

@@ -11,6 +11,7 @@
<ul class="nav ace-nav">
<li><a href="/mixes">Mixes</a></li>
<li><a href="/users">Users</a></li>
<li><a class="btn-danger" data-bypass="true" id="header-donate-button">Donate</a></li>
{% if false %}
<li class="purple">
<a data-bypass="true" id="header-live-button">&nbsp;Listen Live

View File

@@ -0,0 +1,33 @@
{% extends 'views/dlg/_DialogBase.html' %}
{% load account %}
{% load static %}
{% load socialaccount %}
{% block header %}
<h3>Show Me The Money!!</h3>
{% endblock %}
{% block content %}
<script type="text/javascript">
$('#submit')
</script>
<div class="well">
While the site is free and always will be free, bandwidth and disk space aren't. <br/>
Any support is gratefully received...
</div>
<form id="paypal-form" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="29VBHXWZNV8VQ">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1"
height="1">
</form>
<p>
<button class="btn btn-pink" name="submit">
<i class="icon-euro bigger-125"></i>Paypal
</button>
<button class="btn btn-green" name="bitcoins" id="bitcoins">
<i class="icon-bitcoin align-top bigger-125"></i>Bitcoins
</button>
</p>
{% endblock %}
{% block primarybutton %}Okies...{% endblock %}