Permalink
Browse files

Import project django-audiofield

  • Loading branch information...
1 parent 73899fe commit 1ee84c50786102e49ad6772bf9a2b05c72e34c75 @areski committed Dec 8, 2011
Showing with 11,287 additions and 0 deletions.
  1. +9 −0 .gitignore
  2. +55 −0 HACKING
  3. +9 −0 MANIFEST.in
  4. +18 −0 MIT-LICENSE.txt
  5. +137 −0 README.rst
  6. +10 −0 TODO
  7. 0 README → audiofield/__init__.py
  8. +33 −0 audiofield/admin.py
  9. +247 −0 audiofield/fields.py
  10. +10 −0 audiofield/forms.py
  11. 0 audiofield/middleware/__init__.py
  12. +17 −0 audiofield/middleware/threadlocals.py
  13. +50 −0 audiofield/models.py
  14. +2 −0 audiofield/requirements.txt
  15. BIN audiofield/static/audiofield/_mp3/Rain on Car Roof.aac
  16. BIN audiofield/static/audiofield/_mp3/duck.wav
  17. BIN audiofield/static/audiofield/_mp3/rain.mp3
  18. BIN audiofield/static/audiofield/_mp3/sample_ogg.ogg
  19. BIN audiofield/static/audiofield/_mp3/select.mp3
  20. BIN audiofield/static/audiofield/_mp3/sine, square, sawtooth, rando.mp3
  21. BIN audiofield/static/audiofield/_mp3/walking.mp3
  22. BIN audiofield/static/audiofield/_mp3/webconf.wav
  23. +36 −0 audiofield/static/audiofield/flashblock/basic.html
  24. +130 −0 audiofield/static/audiofield/flashblock/flashblock.css
  25. +128 −0 audiofield/static/audiofield/flashblock/index.html
  26. +61 −0 audiofield/static/audiofield/flashblock/method1/flashblock.css
  27. +90 −0 audiofield/static/audiofield/flashblock/method1/flashblock.js
  28. +76 −0 audiofield/static/audiofield/flashblock/method1/index.html
  29. +104 −0 audiofield/static/audiofield/page-player/basic.html
  30. +124 −0 audiofield/static/audiofield/page-player/css/demo.css
  31. +168 −0 audiofield/static/audiofield/page-player/css/optional-annotations.css
  32. +206 −0 audiofield/static/audiofield/page-player/css/optional-themes.css
  33. +320 −0 audiofield/static/audiofield/page-player/css/page-player.css
  34. BIN audiofield/static/audiofield/page-player/image/divot-bottom.png
  35. BIN audiofield/static/audiofield/page-player/image/divot.png
  36. BIN audiofield/static/audiofield/page-player/image/top-highlight.png
  37. +142 −0 audiofield/static/audiofield/page-player/script/optional-page-player-metadata.js
  38. +1,079 −0 audiofield/static/audiofield/page-player/script/page-player.js
  39. +102 −0 audiofield/static/audiofield/script/soundmanager2-jsmin.js
  40. +74 −0 audiofield/static/audiofield/script/soundmanager2-nodebug-jsmin.js
  41. +2,162 −0 audiofield/static/audiofield/script/soundmanager2-nodebug.js
  42. +4,475 −0 audiofield/static/audiofield/script/soundmanager2.js
  43. BIN audiofield/static/audiofield/swf/soundmanager2.swf
  44. BIN audiofield/static/audiofield/swf/soundmanager2_debug.swf
  45. BIN audiofield/static/audiofield/swf/soundmanager2_flash9.swf
  46. BIN audiofield/static/audiofield/swf/soundmanager2_flash9_debug.swf
  47. BIN audiofield/static/audiofield/swf/soundmanager2_flash_xdomain.zip
  48. +62 −0 audiofield/templates/common_audiofield.html
  49. +136 −0 audiofield/widgets.py
  50. +130 −0 docs/Makefile
  51. +170 −0 docs/make.bat
  52. BIN docs/source/_static/django-admin-audiofield-upload.png
  53. BIN docs/source/_static/django-admin-audiofield.png
  54. +216 −0 docs/source/conf.py
  55. +16 −0 docs/source/developer-doc.rst
  56. +97 −0 docs/source/developer-doc/form.rst
  57. +23 −0 docs/source/developer-doc/objects-description.rst
  58. +8 −0 docs/source/developer-doc/pre-requisite.rst
  59. +18 −0 docs/source/developer-doc/testing.rst
  60. +143 −0 docs/source/includes/introduction.txt
  61. +29 −0 docs/source/index.rst
  62. +68 −0 docs/source/installation-overview.rst
  63. +7 −0 docs/source/introduction.rst
  64. +90 −0 setup.py
View
@@ -0,0 +1,9 @@
+*.pyc
+*dilla*
+*.db
+*nbproject*
+*devserver*
+*.idea*
+test.db
+settings_local.py
+docs/build/*
View
55 HACKING
@@ -0,0 +1,55 @@
+Nova Style Commandments
+=======================
+
+Step 1: Read http://www.python.org/dev/peps/pep-0008/
+Step 2: Read http://www.python.org/dev/peps/pep-0008/ again
+Step 3: Read on
+
+Imports
+-------
+- thou shalt not import objects, only modules
+- thou shalt not import more than one module per line
+- thou shalt not make relative imports
+- thou shalt "from nova import vendor" before importing third party code
+- thou shalt organize your imports according to the following template
+
+::
+ # vim: tabstop=4 shiftwidth=4 softtabstop=4
+ {{stdlib imports in human alphabetical order}}
+ \n
+ from nova import vendor
+ {{vendor imports in human alphabetical order}}
+ \n
+ {{nova imports in human alphabetical order}}
+ \n
+ \n
+ {{begin your code}}
+
+
+General
+-------
+- thou shalt put two newlines twixt toplevel code (funcs, classes, etc)
+- thou shalt put one newline twixt methods in classes and anywhere else
+- thou shalt not write "except:", use "except Exception:" at the very least
+- thou shalt include your name with TODOs as in "TODO(termie)"
+- thou shalt not name anything the same name as a builtin or reserved word
+- thou shalt not violate causality in our time cone, or else
+
+
+Human Alphabetical Order Examples
+---------------------------------
+::
+ import httplib
+ import logging
+ import random
+ import StringIO
+ import time
+ import unittest
+
+
+
+Tool to make code PEP8 compliant
+--------------------------------
+- Install : https://github.com/cburroughs/pep8
+- Usage in your project directory : pep8 --statistics --filename=*.py --show-source --show-pep8 .
+
View
@@ -0,0 +1,9 @@
+global-exclude *.pyc
+
+include README.rst
+include COPYING
+
+
+recursive-include audiofield *
+
+
View
@@ -0,0 +1,18 @@
+Copyright (c) 2011 Star2Billing S.L. <info@star2billing.com>
+
+django-audiofield is distributed under the terms of the Mozilla Public License (MPL) Version 1.1
+
+
+The contents of this file are subject to the Mozilla Public License Version
+1.1 (the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+http://www.mozilla.org/MPL/
+
+Software distributed under the License is distributed on an "AS IS" basis,
+WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+for the specific language governing rights and limitations under the License.
+
+
+You must retain, in the Source form of any Derivative Works that You distribute, all
+copyright, patent, trademark, and attribution notices from the Source form of the Work
+and a copy of this License excluding those notices that do not pertain to any part of the Derivative Works.
View
@@ -0,0 +1,137 @@
+=================
+django-audiofield
+=================
+
+
+Installation
+============
+
+Install Django-Audiofield::
+
+ python setup.py install
+
+
+Dependencies
+------------
+
+Install dependencies on Debian::
+
+ apt-get -y install libsox-fmt-mp3 libsox-fmt-all mpg321 ffmpeg
+
+
+Install dependencies on Redhat/CentOS::
+
+ yum -y install python-setuptools libsox-fmt-mp3 libsox-fmt-all mpg321 ffmpeg
+
+
+Settings
+========
+
+in your settings.py file::
+
+ # Set Following variable
+ #MEDIA_ROOT = ''
+
+ #MEDIA_URL = ''
+
+ In MIDDLEWARE_CLASSES add 'audiofield.middleware.threadlocals.ThreadLocals'
+
+ In INSTALLED_APPS add 'audiofield'
+
+
+Usage
+=====
+
+Add the following lines in your models.py file::
+
+ from django.conf import settings
+ from audiofield.fields import AudioField
+ import os.path
+
+ # Add the audio field to your model
+ audio_file = AudioField(upload_to='your/upload/dir', blank=True,
+ ext_whitelist=(".mp3", ".wav", ".ogg"),
+ help_text=("Allowed type - .mp3, .wav, .ogg"))
+
+
+ # Add this method to your model
+ def audio_file_player(self):
+ """audio player tag for admin"""
+ if self.audio_file:
+ file_url = settings.MEDIA_URL + str(self.audio_file)
+ player_string = '<ul class="playlist"><li style="width:250px;">\
+ <a href="%s">%s</a></li></ul>' % (file_url, os.path.basename(self.audio_file.name))
+ return player_string
+ audio_file_player.allow_tags = True
+ audio_file_player.short_description = _('Audio file player')
+
+
+Add the following lines in your admin.py::
+
+
+ from your_app.models import your_model_name
+
+ # add 'audio_file_player' tag to your admin view
+ list_display = (..., 'audio_file_player', ...)
+
+
+If you are not using the installation script, please copy following template
+file to your template directory::
+
+ cp audiofield/templates/common_audiofield.html /path/to/your/templates/directory/
+
+
+Add the following in your template files (like admin/change_form.html, admin/change_list.html etc.
+in which you are using audio field type)::
+
+
+ {% block extrahead %}
+ {{ block.super }}
+ {% include "common_audiofield.html" %}
+ {% endblock %}
+
+
+Then perform following commands to create the table and collect the static files::
+
+ ./manage.py syncdb
+
+ ./manage.py collectstatic
+
+
+Create audiofield.log file::
+
+ touch /var/log/audio-field.log
+
+
+
+Contributing
+============
+
+If you've found a bug, implemented a feature or customized the template and
+think it is useful then please consider contributing. Patches, pull requests or
+just suggestions are welcome!
+
+Source code: http://github.com/Star2Billing/django-audiofield
+
+
+If you don’t like Github and Git you’re welcome to send regular patches.
+
+Bug tracker: https://github.com/Star2Billing/django-audiofield/issues
+
+
+
+License
+=======
+
+Copyright (c) 2011 Star2Billing S.L. <info@star2billing.com>
+
+django-audiofield is licensed under MIT, see `MIT-LICENSE.txt`.
+
+
+Credit
+======
+
+Django-audiofield is a Star2Billing-Sponsored Community Project, for more information visit
+http://www.star2billing.com or email us at info@star2billing.com
+
+
View
10 TODO
@@ -0,0 +1,10 @@
+
+====
+TODO
+====
+
+
+- Add test
+
+
+
File renamed without changes.
View
@@ -0,0 +1,33 @@
+from django.contrib import admin
+from django.db.models import *
+from audiofield.models import AudioFile
+from django.conf import settings
+from django.utils.translation import ugettext as _
+import os
+
+
+class AudioFileAdmin(admin.ModelAdmin):
+ """Allows the administrator to view and modify uploaded audio files"""
+ list_display = ('id', 'name', 'audio_file_player', 'user')
+ #list_display_links = ['id', 'name',]
+ ordering = ('id', )
+
+ actions = ['custom_delete_selected']
+
+ def custom_delete_selected(self, request, queryset):
+ #custom delete code
+ n = queryset.count()
+ for i in queryset:
+ if i.audio_file:
+ if os.path.exists(i.audio_file.path):
+ os.remove(i.audio_file.path)
+ i.delete()
+ self.message_user(request, _("Successfully deleted %d audio files.") % n)
+ custom_delete_selected.short_description = "Delete selected items"
+
+ def get_actions(self, request):
+ actions = super(AudioFileAdmin, self).get_actions(request)
+ del actions['delete_selected']
+ return actions
+
+admin.site.register(AudioFile, AudioFileAdmin)
Oops, something went wrong.

0 comments on commit 1ee84c5

Please sign in to comment.