Skip to content
Browse files

Merge branch 'master' of github.com:danieleguido/walt

  • Loading branch information...
2 parents a18b08d + 9e66dff commit 3f302ad58143a358923701254d75a121b569c376 @danieleguido committed Mar 4, 2013
Showing with 135 additions and 77 deletions.
  1. +4 −2 glue/admin.py
  2. +55 −49 glue/models.py
  3. +1 −0 static/less/style.less
  4. +49 −22 templates/walt/index.html
  5. +16 −2 templates/walt/walt.html
  6. +10 −2 walt/views.py
View
6 glue/admin.py
@@ -1,5 +1,5 @@
from django.contrib import admin
-from glue.models import Page, Pin, Tag
+from glue.models import Page, Pin, Tag, Serie, Frame
class TagAdmin(admin.ModelAdmin):
@@ -8,4 +8,6 @@ class TagAdmin(admin.ModelAdmin):
admin.site.register( Page )
admin.site.register( Pin )
-admin.site.register( Tag, TagAdmin )
+admin.site.register( Tag, TagAdmin )
+admin.site.register( Serie )
+admin.site.register( Frame )
View
104 glue/models.py
@@ -3,55 +3,6 @@
from django.db import models
-class Serie( models.Model ):
-
- KEY = "Ke"
- GHOST = "GH" # a non published serie ?
- GHOST = "GH"
-
- TYPE_CHOICES = (
- (KEY, 'key frame'),
- (GHOST, 'ghost'),
- )
-
- slug = models.SlugField( unique=True )
- title = models.CharField( max_length=160, default="", blank=True, null=True )
- abstract = models.TextField( default="", blank=True, null=True )
- content = models.TextField( default="", blank=True, null=True )
-
- type = models.CharField( max_length=2, choices=TYPE_CHOICES ) # if true, serie is a default serie
-
- date = models.DateField( blank=True, null=True ) # main date, manually added
- date_last_modified = models.DateField( auto_now=True ) # date last save()
-
-
- frames = models.ManyToManyField( Pin, through='Frame', null=True, blank=True )
- related = models.ManyToManyField("self", symmetrical=True, null=True, blank=True )
-
-
-
-class Frame( models.Model ):
-
- KEY = "Ke"
- GHOST = "GH" # visible but just for reference.
-
-
- TYPE_CHOICES = (
- (KEY, 'key frame'),
- (GHOST, 'ghost'),
- )
-
- pin = models.ForeignKey( Pin )
- serie = models.ForeignKey( Serie )
- sort = models.IntegerField( default=0 )
-
- type = models.CharField( max_length=2, choices=TYPE_CHOICES )
-
- abstract = models.TextField( default="", blank=True, null=True ) # a description of the passage
-
- class Meta:
- unique_together = ( "serie", "sort" )
- ordering = ('sort' )
class Geo( models.Model): # geo spot, with zoom
@@ -172,3 +123,58 @@ def json( self ):
class Page( PageAbstract ):
pins = models.ManyToManyField( Pin, null=True, blank=True, related_name="page")
+
+
+
+class Serie( models.Model ):
+ # note: Serie are not unique, but
+ MAIN = "Mn"
+ GHOST = "Gh" # a non published serie ?
+ SIBLING = "Sb" # a sibling
+
+ TYPE_CHOICES = (
+ (MAIN, 'main or default serie'), # normally editable only by staff
+ (GHOST, 'ghost'),
+ (SIBLING, 'sibling'),
+ )
+
+ slug = models.SlugField( )
+ title = models.CharField( max_length=160, default="", blank=True, null=True )
+ abstract = models.TextField( default="", blank=True, null=True )
+ content = models.TextField( default="", blank=True, null=True ) # a looong description
+ sort = models.IntegerField( default=0 )
+
+ type = models.CharField( max_length=2, choices=TYPE_CHOICES, default=SIBLING )
+
+ date = models.DateField( blank=True, null=True ) # main date, manually added
+ date_last_modified = models.DateField( auto_now=True ) # date last save()
+
+ related = models.ManyToManyField("self", symmetrical=True, null=True, blank=True )
+ frames = models.ManyToManyField( Pin, through='Frame', null=True, blank=True )
+ users = models.ManyToManyField( User, blank=True, null=True ) # authors
+
+
+
+class Frame( models.Model ):
+
+ KEY = "Ke"
+ GHOST = "Gh" # visible but just for reference.
+ SIMPLE = "Sl" # visible but just for reference.
+
+ TYPE_CHOICES = (
+ (KEY, 'key frame'),
+ (GHOST, 'ghost'),
+ (SIMPLE, 'simple frame'),
+ )
+
+ pin = models.ForeignKey( Pin )
+ serie = models.ForeignKey( Serie )
+ sort = models.IntegerField( default=0 )
+
+ type = models.CharField( max_length=2, choices=TYPE_CHOICES, default=SIMPLE )
+
+ abstract = models.TextField( default="", blank=True, null=True ) # a description of the passage
+
+ class Meta:
+ unique_together = ( "serie", "sort" )
+ ordering = ('sort', )
View
1 static/less/style.less
@@ -46,6 +46,7 @@ h2{
.timeline{
width: 100%;
+ height: 30px;
.inner{
position:absolute;
View
71 templates/walt/index.html
@@ -4,31 +4,31 @@
{% block page %}
<div class="grid_12">
- <h2 style="border-width:0px">Protocols</h2>
+ <h2 style="border-width:0px">{% trans "series" %} ( {{ series.count }} )</h2>
- <div class="stories">
- <div class="story">
- <div class="title">Grimm fairy tale analysis. <span><a href="#">play</a></span></div>
+ <div class="series">
+ {% for serie in series %}
+ <div class="serie">
+ <div class="title">{{ serie.title }}. <span><a href="#">play</a></span></div>
+ <div class="frames">
+ {% for frame in serie.frames.all %}
+ <span>{{ frame.id }}</span>
+ {% endfor %}
+ </div>
<div class="timeline">
+
<div class="inner">
<div class="start">1867 &rarr;</div>
<div class="end">2013</div>
</div>
+
</div>
+ <div class="clear"></div>
</div>
-
- <div class="story">
- <div class="title">Learn how to get more value out of metadata easily <span><a href="#">play</a></span></div>
- <div class="timeline">
- <div class="inner">
- <div class="start">2005 &rarr;</div>
-
- <div class="end">2013</div>
- </div>
- </div>
- </div>
+ {% endfor %}
+
</div>
</div>
@@ -73,17 +73,44 @@ <h2 style="border-width:0px">Protocols</h2>
</div>
- <div class="grid_3">
- <h2>{{ walt.ask.title }}
- <div class="description">
- {{ walt.ask.abstract }} ( {{ walt.ask.pins.count }} )
- </div>
- </h2>
+ <div class="grid_3 alpha">
+ <a href="{% url walt_a %}"><h2>{{ walt.ask.title }}
+ <div class="description">
+ {{ walt.ask.abstract }} ( {{ walt.ask.pins.count }} )
+ </div>
+ </h2>
+ </a>
<div class="items">
+ {% for pin in walt.ask.pins.all|slice:":10" %}
<div class="item">
- <iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F80053791"></iframe>
+
+ <h3>#{{ pin.id }} {{ pin.title }} </h3>
+ <div class="metadata"><span class="date">{% if pin.date %}{{ pin.date }}{% else %}{{ pin.date_last_modified }}{% endif %}</span>
+ {% for tag in pin.tags.all %}
+ <a href="{% url walt_tag tag.type|lower tag.slug %}" class="tag" alt="{{ tag.name }} ( {{ tag.type }} )">{{ tag.name }}</a>
+ {% if not forloop.last %},{%endif %}
+ {% endfor %}
+ <p><a href="{% url admin:glue_pin_change pin.id %}">&rarr; {% trans "edit" %}</a></p>
+ </div>
+ <blockquote>
+ {{ pin.abstract }}
+
+ </blockquote>
+ {{ pin.content|safe }}
+ <a class="external" href="{{ pin.permalink}}">&rarr; {{ pin.permalink}}</a>
+
+ {% for child in pin.children.all|slice:":10" %}
+ <div class="comment">
+ <a href="#" class="author"> </a> {{ child.abstract }}
+ </div>
+ {% endfor %}
+
</div>
+ {% endfor %}
+
</div>
+
+
</div>
<div class="grid_3">
<h2>{{ walt.learn.title }}
View
18 templates/walt/walt.html
@@ -57,6 +57,7 @@ <h2 style="border-width:0px">Protocols</h2>
{{ pin.abstract }}
</blockquote>
+ {{ pin.content|safe }}
<a class="external" href="{{ pin.permalink}}">&rarr; {{ pin.permalink}}</a>
{% for child in pin.children.all|slice:":10" %}
@@ -71,11 +72,24 @@ <h2 style="border-width:0px">Protocols</h2>
</div>
</div>
<div class="grid_6 omega">
- <h2>{% trans "top protocols" %}
+ <h2>{% trans "series" %}( {{ series.count }} )
<div class="description">
- protocols using mostly wander items ( {{ page.pins.count }} )
+ series or protocols using 'wander' items
</div>
+
+
</h2>
+
+ <div class="items">
+ {% for serie in series %}
+ <div class="item">
+ <h3>{{ serie.title }}</h3>
+ <div class="abstract">
+ {{ serie.abstract }}
+ </div>
+ </div>
+ {% endfor %}
+ </div>
</div>
</div>
View
12 walt/views.py
@@ -12,7 +12,7 @@
from django.utils.translation import get_language
from glue.forms import LoginForm, AddPinForm, EditPinForm
-from glue.models import Pin, Page
+from glue.models import Pin, Page, Serie
logger = logging.getLogger('glue')
@@ -46,6 +46,7 @@ def sc( request, tags=[], d={}, load_walt=True ):
def home( request ):
data = sc( request, tags=[ "home" ] )
+ data['series'] = Serie.objects.all()
return render_to_response( "walt/index.html", RequestContext(request, data ) )
@@ -54,22 +55,29 @@ def tag( request, tag_type, tag_slug ):
return render_to_response( "walt/index.html", RequestContext(request, data ) )
+def _walt( data, slug ):
+ data['page'] = get_object_or_404( Page, language=data['language'], slug=slug )
+ data['series'] = Serie.objects.filter( frame__pin__page__slug=slug ).distinct()
+ return data
def waltw( request ):
data = sc( request, tags=[ "w" ] )
- data['page'] = get_object_or_404( Page, language=data['language'], slug=WALT_W )
+ data = _walt( data, WALT_W )
return render_to_response( "walt/walt.html", RequestContext(request, data ) )
def walta( request ):
data = sc( request, tags=[ "a" ] )
+ data = _walt( data, WALT_A )
return render_to_response( "walt/walt.html", RequestContext(request, data ) )
def waltl( request ):
data = sc( request, tags=[ "l" ] )
+ data = _walt( data, WALT_L )
return render_to_response( "walt/walt.html", RequestContext(request, data ) )
def waltt( request ):
data = sc( request, tags=[ "t" ] )
+ data = _walt( data, WALT_T )
return render_to_response( "walt/walt.html", RequestContext(request, data ) )
# call this function once. It will check for page availability and other stories...

0 comments on commit 3f302ad

Please sign in to comment.
Something went wrong with that request. Please try again.