Permalink
Browse files

Merge branch 'new'

  • Loading branch information...
brosner committed Nov 30, 2010
2 parents d695670 + db75213 commit b9590ec3fc5214b3397d963a631afa942ebf4606
Showing with 4,018 additions and 961 deletions.
  1. +1 −1 LICENSE
  2. +1 −1 README.rst
  3. +2 −2 mimesis/__init__.py
  4. +3 −4 mimesis/admin.py
  5. +0 −16 mimesis/decorators.py
  6. +0 −10 mimesis/forms.py
  7. +17 −0 mimesis/managers.py
  8. +67 −60 mimesis/models.py
  9. 0 {photo_project/apps → mimesis/templatetags}/__init__.py
  10. +116 −0 mimesis/templatetags/mimesis_tags.py
  11. +0 −1 mimesis/tests/__init__.py
  12. +0 −63 mimesis/tests/test_form.py
  13. +0 −25 mimesis/urls.py
  14. +1 −159 mimesis/views.py
  15. 0 {photo_project → mimesis_project}/__init__.py
  16. 0 {photo_project/apps/main → mimesis_project/apps}/__init__.py
  17. 0 {photo_project → mimesis_project}/deploy/__init__.py
  18. +11 −0 mimesis_project/deploy/pinax.fcgi
  19. +11 −0 mimesis_project/deploy/pinax.wsgi
  20. 0 {photo_project → mimesis_project}/fixtures/initial_data.json
  21. BIN mimesis_project/locale/ar/LC_MESSAGES/django.mo
  22. +66 −0 mimesis_project/locale/ar/LC_MESSAGES/django.po
  23. BIN mimesis_project/locale/bg/LC_MESSAGES/django.mo
  24. +63 −0 mimesis_project/locale/bg/LC_MESSAGES/django.po
  25. BIN mimesis_project/locale/bn/LC_MESSAGES/django.mo
  26. +63 −0 mimesis_project/locale/bn/LC_MESSAGES/django.po
  27. BIN mimesis_project/locale/bs/LC_MESSAGES/django.mo
  28. +63 −0 mimesis_project/locale/bs/LC_MESSAGES/django.po
  29. BIN mimesis_project/locale/ca/LC_MESSAGES/django.mo
  30. +64 −0 mimesis_project/locale/ca/LC_MESSAGES/django.po
  31. BIN mimesis_project/locale/cs/LC_MESSAGES/django.mo
  32. +64 −0 mimesis_project/locale/cs/LC_MESSAGES/django.po
  33. BIN mimesis_project/locale/cy/LC_MESSAGES/django.mo
  34. +63 −0 mimesis_project/locale/cy/LC_MESSAGES/django.po
  35. BIN mimesis_project/locale/da/LC_MESSAGES/django.mo
  36. +63 −0 mimesis_project/locale/da/LC_MESSAGES/django.po
  37. BIN mimesis_project/locale/de/LC_MESSAGES/django.mo
  38. +64 −0 mimesis_project/locale/de/LC_MESSAGES/django.po
  39. BIN mimesis_project/locale/el/LC_MESSAGES/django.mo
  40. +64 −0 mimesis_project/locale/el/LC_MESSAGES/django.po
  41. BIN mimesis_project/locale/en/LC_MESSAGES/django.mo
  42. +63 −0 mimesis_project/locale/en/LC_MESSAGES/django.po
  43. BIN mimesis_project/locale/es/LC_MESSAGES/django.mo
  44. +64 −0 mimesis_project/locale/es/LC_MESSAGES/django.po
  45. BIN mimesis_project/locale/es_AR/LC_MESSAGES/django.mo
  46. +64 −0 mimesis_project/locale/es_AR/LC_MESSAGES/django.po
  47. BIN mimesis_project/locale/et/LC_MESSAGES/django.mo
  48. +63 −0 mimesis_project/locale/et/LC_MESSAGES/django.po
  49. BIN mimesis_project/locale/eu/LC_MESSAGES/django.mo
  50. +63 −0 mimesis_project/locale/eu/LC_MESSAGES/django.po
  51. BIN mimesis_project/locale/fa/LC_MESSAGES/django.mo
  52. +63 −0 mimesis_project/locale/fa/LC_MESSAGES/django.po
  53. BIN mimesis_project/locale/fi/LC_MESSAGES/django.mo
  54. +64 −0 mimesis_project/locale/fi/LC_MESSAGES/django.po
  55. BIN mimesis_project/locale/fr/LC_MESSAGES/django.mo
  56. +148 −0 mimesis_project/locale/fr/LC_MESSAGES/django.po
  57. BIN mimesis_project/locale/fy_NL/LC_MESSAGES/django.mo
  58. +63 −0 mimesis_project/locale/fy_NL/LC_MESSAGES/django.po
  59. BIN mimesis_project/locale/ga/LC_MESSAGES/django.mo
  60. +65 −0 mimesis_project/locale/ga/LC_MESSAGES/django.po
  61. BIN mimesis_project/locale/gl/LC_MESSAGES/django.mo
  62. +63 −0 mimesis_project/locale/gl/LC_MESSAGES/django.po
  63. BIN mimesis_project/locale/he/LC_MESSAGES/django.mo
  64. +64 −0 mimesis_project/locale/he/LC_MESSAGES/django.po
  65. BIN mimesis_project/locale/hi/LC_MESSAGES/django.mo
  66. +63 −0 mimesis_project/locale/hi/LC_MESSAGES/django.po
  67. BIN mimesis_project/locale/hr/LC_MESSAGES/django.mo
  68. +65 −0 mimesis_project/locale/hr/LC_MESSAGES/django.po
  69. BIN mimesis_project/locale/hu/LC_MESSAGES/django.mo
  70. +64 −0 mimesis_project/locale/hu/LC_MESSAGES/django.po
  71. BIN mimesis_project/locale/is/LC_MESSAGES/django.mo
  72. +64 −0 mimesis_project/locale/is/LC_MESSAGES/django.po
  73. BIN mimesis_project/locale/it/LC_MESSAGES/django.mo
  74. +64 −0 mimesis_project/locale/it/LC_MESSAGES/django.po
  75. BIN mimesis_project/locale/ja/LC_MESSAGES/django.mo
  76. +64 −0 mimesis_project/locale/ja/LC_MESSAGES/django.po
  77. BIN mimesis_project/locale/ka/LC_MESSAGES/django.mo
  78. +63 −0 mimesis_project/locale/ka/LC_MESSAGES/django.po
  79. BIN mimesis_project/locale/km/LC_MESSAGES/django.mo
  80. +64 −0 mimesis_project/locale/km/LC_MESSAGES/django.po
  81. BIN mimesis_project/locale/kn/LC_MESSAGES/django.mo
  82. +63 −0 mimesis_project/locale/kn/LC_MESSAGES/django.po
  83. BIN mimesis_project/locale/ko/LC_MESSAGES/django.mo
  84. +63 −0 mimesis_project/locale/ko/LC_MESSAGES/django.po
  85. BIN mimesis_project/locale/lt/LC_MESSAGES/django.mo
  86. +63 −0 mimesis_project/locale/lt/LC_MESSAGES/django.po
  87. BIN mimesis_project/locale/lv/LC_MESSAGES/django.mo
  88. +63 −0 mimesis_project/locale/lv/LC_MESSAGES/django.po
  89. BIN mimesis_project/locale/mk/LC_MESSAGES/django.mo
  90. +64 −0 mimesis_project/locale/mk/LC_MESSAGES/django.po
  91. BIN mimesis_project/locale/nl/LC_MESSAGES/django.mo
  92. +64 −0 mimesis_project/locale/nl/LC_MESSAGES/django.po
  93. BIN mimesis_project/locale/no/LC_MESSAGES/django.mo
  94. +63 −0 mimesis_project/locale/no/LC_MESSAGES/django.po
  95. BIN mimesis_project/locale/pl/LC_MESSAGES/django.mo
  96. +65 −0 mimesis_project/locale/pl/LC_MESSAGES/django.po
  97. BIN mimesis_project/locale/pt/LC_MESSAGES/django.mo
  98. +63 −0 mimesis_project/locale/pt/LC_MESSAGES/django.po
  99. BIN mimesis_project/locale/pt_BR/LC_MESSAGES/django.mo
  100. +64 −0 mimesis_project/locale/pt_BR/LC_MESSAGES/django.po
  101. BIN mimesis_project/locale/ro/LC_MESSAGES/django.mo
  102. +64 −0 mimesis_project/locale/ro/LC_MESSAGES/django.po
  103. BIN mimesis_project/locale/ru/LC_MESSAGES/django.mo
  104. +87 −0 mimesis_project/locale/ru/LC_MESSAGES/django.po
  105. BIN mimesis_project/locale/sk/LC_MESSAGES/django.mo
  106. +64 −0 mimesis_project/locale/sk/LC_MESSAGES/django.po
  107. BIN mimesis_project/locale/sl/LC_MESSAGES/django.mo
  108. +65 −0 mimesis_project/locale/sl/LC_MESSAGES/django.po
  109. BIN mimesis_project/locale/sq/LC_MESSAGES/django.mo
  110. +63 −0 mimesis_project/locale/sq/LC_MESSAGES/django.po
  111. BIN mimesis_project/locale/sr/LC_MESSAGES/django.mo
  112. +65 −0 mimesis_project/locale/sr/LC_MESSAGES/django.po
  113. BIN mimesis_project/locale/sr_Latn/LC_MESSAGES/django.mo
  114. +65 −0 mimesis_project/locale/sr_Latn/LC_MESSAGES/django.po
  115. BIN mimesis_project/locale/sv/LC_MESSAGES/django.mo
  116. +64 −0 mimesis_project/locale/sv/LC_MESSAGES/django.po
  117. BIN mimesis_project/locale/ta/LC_MESSAGES/django.mo
  118. +125 −0 mimesis_project/locale/ta/LC_MESSAGES/django.po
  119. BIN mimesis_project/locale/te/LC_MESSAGES/django.mo
  120. +64 −0 mimesis_project/locale/te/LC_MESSAGES/django.po
  121. BIN mimesis_project/locale/th/LC_MESSAGES/django.mo
  122. +64 −0 mimesis_project/locale/th/LC_MESSAGES/django.po
  123. BIN mimesis_project/locale/tr/LC_MESSAGES/django.mo
  124. +64 −0 mimesis_project/locale/tr/LC_MESSAGES/django.po
  125. BIN mimesis_project/locale/uk/LC_MESSAGES/django.mo
  126. +63 −0 mimesis_project/locale/uk/LC_MESSAGES/django.po
  127. BIN mimesis_project/locale/vi/LC_MESSAGES/django.mo
  128. +64 −0 mimesis_project/locale/vi/LC_MESSAGES/django.po
  129. BIN mimesis_project/locale/zh_CN/LC_MESSAGES/django.mo
  130. +64 −0 mimesis_project/locale/zh_CN/LC_MESSAGES/django.po
  131. BIN mimesis_project/locale/zh_TW/LC_MESSAGES/django.mo
  132. +64 −0 mimesis_project/locale/zh_TW/LC_MESSAGES/django.po
  133. +21 −0 mimesis_project/manage.py
  134. 0 {photo_project → mimesis_project}/media/README
  135. +2 −2 {photo_project → mimesis_project}/requirements/base.txt
  136. +2 −5 {photo_project → mimesis_project}/requirements/project.txt
  137. +6 −12 {photo_project → mimesis_project}/settings.py
  138. +11 −0 {photo_project → mimesis_project}/templates/homepage.html
  139. +2 −4 {photo_project → mimesis_project}/templates/site_base.html
  140. +1 −1 {photo_project → mimesis_project}/urls.py
  141. +0 −5 photo_project/apps/main/context_processors.py
  142. +0 −17 photo_project/deploy/pinax.fcgi
  143. +0 −17 photo_project/deploy/pinax.wsgi
  144. +0 −28 photo_project/manage.py
  145. 0 photo_project/media/css/site_tabs.css
  146. BIN photo_project/media/js/uploadify/cancel.png
  147. +0 −35 photo_project/media/js/uploadify/check.php
  148. BIN photo_project/media/js/uploadify/expressInstall.swf
  149. +0 −19 photo_project/media/js/uploadify/jquery-1.3.2.min.js
  150. BIN photo_project/media/js/uploadify/jquery.uploadify-v2.1.0.zip
  151. +0 −26 photo_project/media/js/uploadify/jquery.uploadify.js
  152. +0 −4 photo_project/media/js/uploadify/swfobject.js
  153. BIN photo_project/media/js/uploadify/uploadify.allglyphs.swf
  154. +0 −53 photo_project/media/js/uploadify/uploadify.css
  155. BIN photo_project/media/js/uploadify/uploadify.fla
  156. +0 −46 photo_project/media/js/uploadify/uploadify.php
  157. BIN photo_project/media/js/uploadify/uploadify.swf
  158. +0 −92 photo_project/templates/mimesis/album.html
  159. +0 −39 photo_project/templates/mimesis/albums.html
  160. +0 −23 photo_project/templates/mimesis/base.html
  161. +0 −136 photo_project/templates/mimesis/index.html
  162. +0 −20 photo_project/templates/mimesis/photo.html
  163. +0 −33 photo_project/templates/mimesis/recent.html
  164. +2 −1 requirements/app.txt
  165. +2 −1 setup.py
View
@@ -1,4 +1,4 @@
Copyright (c) 2009, Eldarion, Inc.
Copyright (c) 2010, Eldarion, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
View
@@ -2,6 +2,6 @@
mimesis README
==============
mimesis is a simple photo app that includes tagging and albums.
mimesis is a general media management app.
Documentation can be found at http://oss.eldarion.com/mimesis/docs/0.1/
View
@@ -1,4 +1,4 @@
VERSION = (0, 1, 0, "f", 0) # following PEP 386
VERSION = (0, 2, 0, "a", 1) # following PEP 386
DEV_N = 1
@@ -13,4 +13,4 @@ def get_version():
return version
__version__ = get_version()
__version__ = get_version()
View
@@ -1,7 +1,6 @@
from django.contrib import admin
from mimesis.models import Album, Photo
from mimesis.models import Image, ImageAssociation
admin.site.register(Album)
admin.site.register(Photo)
admin.site.register(Image)
admin.site.register(ImageAssociation)
View

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.
View
@@ -0,0 +1,17 @@
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import force_unicode
class MediaAssociationManager(models.Manager):
def for_model(self, model, content_type=None):
"""
QuerySet for all media for a particular model (either an instance or
a class).
"""
ct = content_type or ContentType.objects.get_for_model(model)
qs = self.get_query_set().filter(content_type=ct)
if isinstance(model, models.Model):
qs = qs.filter(object_pk=force_unicode(model._get_pk_val()))
return qs
View
@@ -1,72 +1,79 @@
from datetime import datetime
import datetime
from django.contrib.auth.models import User
from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from mimesis.managers import MediaAssociationManager
from taggit.managers import TaggableManager
class Album(models.Model):
class MediaBase(models.Model):
title = models.CharField(max_length=150)
creator = models.ForeignKey(User)
created = models.DateTimeField(default=datetime.datetime.now)
owner = models.ForeignKey(User)
name = models.CharField(max_length=150)
description = models.TextField(null=True, blank=True)
private = models.BooleanField(default=False)
date_created = models.DateTimeField(default=datetime.now)
tags = TaggableManager()
class Meta:
abstract = True
def __unicode__(self):
return u"%s" % self.name
@property
def key_photo(self): # @@@ This should likely be set by the user
photo = None
for photo in self.photo_set.all().order_by("-uploaded_on"):
break
return photo
class Photo(models.Model):
album = models.ForeignKey(Album, null=True, blank=True)
photo = models.ImageField(
upload_to="mimesis/%Y/%m/%d",
height_field="height",
width_field="width"
)
width = models.IntegerField(blank=True)
height = models.IntegerField(blank=True)
name = models.CharField(max_length=150, null=True, blank=True)
description = models.TextField(null=True, blank=True)
private = models.BooleanField(default=False)
new_upload = models.BooleanField(default=True)
uploaded_by = models.ForeignKey(User)
uploaded_on = models.DateTimeField(default=datetime.now)
return self.title
class MediaAssociationBase(models.Model):
tags = TaggableManager()
content_type = models.ForeignKey(ContentType)
object_pk = models.PositiveIntegerField()
content_object = generic.GenericForeignKey("content_type", "object_pk")
caption = models.TextField(blank=True)
objects = MediaAssociationManager()
class Meta:
abstract = True
class Image(MediaBase):
image = models.ImageField(upload_to="mimesis/image/")
class ImageAssociation(MediaAssociationBase):
image = models.ForeignKey(Image)
def get_absolute_url(self):
return self.image.url
class Audio(MediaBase):
audio = models.FileField(upload_to="mimesis/audio/")
class AudioAssociation(MediaAssociationBase):
audio = models.ForeignKey(Audio)
def get_absolute_url(self):
return self.audio.url
class Video(MediaBase):
video = models.URLField(blank=True)
class VideoAssociation(MediaAssociationBase):
video = models.ForeignKey(Video)
def next_or_prev(self, desc, **kwargs):
order = "id"
if desc:
order = "-id"
if self.album:
p = self.album.photo_set.filter(**kwargs).order_by(order)
if p:
return p[0]
p = self.album.photo_set.all().order_by(order)
if p:
return p[0]
else:
p = self.uploaded_by.photo_set.filter(**kwargs).order_by(order)
if p:
return p[0]
p = self.uploaded_by.photo_set.all().order_by(order)
if p:
return p[0]
def prev(self):
return self.next_or_prev(desc=True, id__lt=self.id)
def next(self):
return self.next_or_prev(desc=False, id__gt=self.id)
def get_absolute_url(self):
return self.video
File renamed without changes.
@@ -0,0 +1,116 @@
from django import template
from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import smart_unicode
from mimesis.models import ImageAssociation, AudioAssociation, VideoAssociation
register = template.Library()
class BaseMediaNode(template.Node):
"""
Base helper class (abstract) for handling the get_media_for template tags.
"""
@classmethod
def handle_token(cls, parser, token, model):
"""Class method to parse get_media_list and return a Node."""
tokens = token.contents.split()
if tokens[1] != 'for':
raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0])
# {% get_whatever for obj as varname %}
if len(tokens) == 5:
if tokens[3] != 'as':
raise template.TemplateSyntaxError("Third argument in %r must be 'as'" % tokens[0])
return cls(
object_expr = parser.compile_filter(tokens[2]),
as_varname = tokens[4],
model = model,
)
# {% get_whatever for app.model pk as varname %}
elif len(tokens) == 6:
if tokens[4] != 'as':
raise template.TemplateSyntaxError("Fourth argument in %r must be 'as'" % tokens[0])
return cls(
ctype = BaseMediaNode.lookup_content_type(tokens[2], tokens[0]),
object_pk_expr = parser.compile_filter(tokens[3]),
as_varname = tokens[5],
model = model,
)
else:
raise template.TemplateSyntaxError("%r tag requires 4 or 5 arguments" % tokens[0])
@staticmethod
def lookup_content_type(token, tagname):
try:
app, model = token.split('.')
return ContentType.objects.get(app_label=app, model=model)
except ValueError:
raise template.TemplateSyntaxError("Third argument in %r must be in the format 'app.model'" % tagname)
except ContentType.DoesNotExist:
raise template.TemplateSyntaxError("%r tag has non-existant content-type: '%s.%s'" % (tagname, app, model))
def __init__(self, ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, model=None):
if ctype is None and object_expr is None:
raise template.TemplateSyntaxError("Media nodes must be given either a literal object or a ctype and object pk.")
self.media_model = model
self.as_varname = as_varname
self.ctype = ctype
self.object_pk_expr = object_pk_expr
self.object_expr = object_expr
def render(self, context):
qs = self.get_query_set(context)
context[self.as_varname] = self.get_context_value_from_queryset(context, qs)
return ""
def get_query_set(self, context):
ctype, object_pk = self.get_target_ctype_pk(context)
if not object_pk:
return self.media_model.objects.none()
qs = self.media_model.objects.filter(
content_type = ctype,
object_pk = smart_unicode(object_pk),
)
return qs
def get_target_ctype_pk(self, context):
if self.object_expr:
try:
obj = self.object_expr.resolve(context)
except template.VariableDoesNotExist:
return None, None
return ContentType.objects.get_for_model(obj), obj.pk
else:
return self.ctype, self.object_pk_expr.resolve(context, ignore_failures=True)
def get_context_value_from_queryset(self, context, qs):
"""Subclasses should override this."""
raise NotImplementedError
class MediaListNode(BaseMediaNode):
"""Insert a list of media into the context."""
def get_context_value_from_queryset(self, context, qs):
return list(qs)
@register.tag
def get_images_for(parser, token):
return MediaListNode.handle_token(parser, token, ImageAssociation)
@register.tag
def get_audio_for(parser, token):
return MediaListNode.handle_token(parser, token, AudioAssociation)
@register.tag
def get_videos_for(parser, token):
return MediaListNode.handle_token(parser, token, VideoAssociation)

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit b9590ec

Please sign in to comment.