Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 47 lines (34 sloc) 1.134 kB
8fa47b7 @coleifer Initial commit of djangoembed, rich media consuming and providing in
coleifer authored
1 import oembed
2 from oembed.providers import DjangoDateBasedProvider, DjangoProvider
3 from oembed.utils import size_to_nearest
4
5 from oembed.tests.models import Blog, Category, Rich
6
7 class BlogProvider(DjangoDateBasedProvider):
8 resource_type = 'link'
9
10 class Meta:
11 model = Blog
12 named_view = 'test_blog_detail'
13 fields_to_match = {'entry_slug': 'slug'}
14 date_field = 'pub_date'
15
16 def author_name(self, obj):
17 return obj.author
18
19 def title(self, obj):
20 return obj.title
21
22 class CategoryProvider(DjangoProvider):
23 resource_type = 'photo'
24
25 class Meta:
26 model = Category
27 named_view = 'test_category_detail'
28 fields_to_match = {'_0': 'pk'}
29
30 def title(self, obj):
31 return obj.name
32
33 class RichProvider(DjangoProvider):
34 resource_type = 'rich'
35
36 class Meta:
37 model = Rich
38 named_view = 'test_rich_detail'
39 fields_to_match = {'_0': 'slug'}
40
41 def title(self, obj):
42 return obj.name
43
44 oembed.site.register(BlogProvider)
45 oembed.site.register(CategoryProvider)
46 oembed.site.register(RichProvider)
Something went wrong with that request. Please try again.