]> git.parisson.com Git - mezzo.git/commitdiff
update doc, add mixins and view methods
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 29 Feb 2016 09:35:20 +0000 (10:35 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 29 Feb 2016 09:35:20 +0000 (10:35 +0100)
README.rst
app/festival/admin.py
app/festival/models.py
app/festival/templates/festival/artist_list.html
app/festival/templates/festival/video_list.html
app/festival/urls.py
app/festival/views.py

index 87c51dfcd6b6ac92be76aa56764ece7ea6f33f9a..75ad623381b5bde21db0bdd7504419073eda3869 100644 (file)
@@ -20,15 +20,18 @@ Run these commands in a terminal::
 
     git clone --recursive git://git.forge.ircam.fr/Manifeste.git
     cd Manifeste
-    docker-compose up
+    docker-compose up db
+
+The last command is needed to init the database. Press CTRL-C to exit. Then fire up the whole composition::
+
+     docker-compose up
 
 To restore the backuped database, in another terminal::
 
     cd Manifeste
     docker-compose run db /srv/backup/restore_db.sh
-    docker-compose run pgdb /srv/backup/restore_db_eve.sh
 
-You should be able to browse the site at http://localhost:8010/
+You should be able to browse the site at http://localhost:9000/
 
 
 MacOS or Windows:
@@ -44,13 +47,15 @@ Run these commands in a terminal::
     cd Manifeste
     docker-compose up
 
+The last command is needed to init the database. Press CTRL-C to exit. Then fire up the whole composition::
+
+    docker-compose up
+
 Then, in another terminal::
 
     eval "$(docker-machine env manifeste)"
     cd Manifeste
-    docker-compose run db /srv/backup/restore_db.sh #(MAJ base festival)
-    docker-compose run pgdb /srv/backup/restore_db_eve.sh #(MAJ base eve)
-
+    docker-compose run db /srv/backup/restore_db.sh
 
 `More info <https://docs.docker.com/>`_ about using docker and related tools.
 The 3rd command should give you the IP of the VM. For example, if IP is 192.168.59.103, you should be able to browse the site at http://192.168.59.103:8010/
index 1438053e59400e290039fc97f49e1864fa825353..e9bd6bf11e30dc8e71ec2a7fd0d84461931d2314 100644 (file)
@@ -20,9 +20,6 @@ class FestivalEventInline(admin.StackedInline):
 
 
 class FestivalEventAdmin(EventAdmin):
-    """
-    Admin class for events.
-    """
 
     inlines = [FestivalEventInline, ]
 
@@ -43,20 +40,10 @@ class VideoAdminDisplayable(DisplayableAdmin):
 
 
 class ArtistAdminDisplayable(DisplayableAdmin):
-    """
-    Admin class for artists.
-    """
 
     fieldsets = deepcopy(ArtistAdmin.fieldsets)
 
 
-    def save_form(self, request, form, change):
-        """
-        Super class ordering is important here - user must get saved first.
-        """
-        return DisplayableAdmin.save_form(self, request, form, change)
-
-
 admin.site.unregister(Event)
 admin.site.register(Event, FestivalEventAdmin)
 
index a39c29c07e8153106ece8ddc4751057e26494b83..ad419e43153c5556a03657c6260e3f3cab262352 100644 (file)
@@ -1,5 +1,6 @@
 from django.db import models
 from django.utils.translation import ugettext_lazy as _
+from django.core.urlresolvers import reverse, reverse_lazy
 
 from mezzanine.core.models import RichText, Displayable
 from mezzanine.core.fields import RichTextField, OrderField, FileField
@@ -72,15 +73,20 @@ class Artist(Displayable, RichText, AdminThumbMixin):
     photo_credits = models.CharField(_('photo credits'), max_length=255, blank=True, null=True)
     featured = models.BooleanField(_('featured'), default=False)
 
-    search_fields = ("name", "bio")
-
-    def __unicode__(self):
-        return self.name
+    search_fields = ("title", "bio")
 
     class Meta(MetaCore):
         verbose_name = _('artist')
         db_table = app_label + '_artists'
 
+    def __unicode__(self):
+        return self.title
+
+    def get_absolute_url(self):
+        url_name = "festival_artist_detail"
+        kwargs = {"slug": self.slug}
+        return reverse(url_name, kwargs=kwargs)
+
 
 class Video(Displayable, RichText):
     """Video"""
@@ -88,13 +94,24 @@ class Video(Displayable, RichText):
     event = models.ForeignKey(Event, related_name='videos', verbose_name=_('event'), blank=True, null=True, on_delete=models.SET_NULL)
     media_id = models.IntegerField(_('media id'))
 
+    class Meta(MetaCore):
+        verbose_name = _('video')
+        db_table = app_label + '_videos'
+
     def __unicode__(self):
-        return
+        return self.title
 
     @property
     def html(self):
         pass
 
+    @models.permalink
+    def get_absolute_url(self):
+        url_name = "festival_video_detail"
+        kwargs = {"slug": self.slug}
+        return reverse(url_name, kwargs=kwargs)
+
+
 class EventCategory(BaseNameModel):
     """Event Category"""
 
index 59248133cabe185ef1dbfe7f6c36d92d5e885287..b921ee80ead4755c24da10046b55771035b29e13 100644 (file)
@@ -7,7 +7,7 @@
 <div class="artist-list">
  <ul>
  {% for artist in object_list %}
-    <li><a href="{% url 'festival-artist-detail' artist.id %}">{{ artist.name }}</a></li>
+    <li><a href="{% url 'festival-artist-detail' artist.slug %}">{{ artist.name }}</a></li>
  {% endfor %}
  </ul>
 </div>
index 33a57d95d4759f873fedecf96531eb5e88da03a3..7add06cf737687bb3503e8cc25436117a3298c3c 100644 (file)
@@ -7,7 +7,7 @@
 <div class="video-list">
  <ul>
  {% for video in object_list %}
-    <li><a href="{% url 'festival-video-detail' video.id %}">{{ video.title }}</a></li>
+    <li><a href="{% url 'festival-video-detail' video.slug %}">{{ video.title }}</a></li>
  {% endfor %}
  </ul>
 </div>
index 04aa490552992c3df08da9962fe3cfd7b7e5c28a..ffed233f75b6a63cae3aa32e2cd2964664ab0ad3 100644 (file)
@@ -11,8 +11,8 @@ from festival.views import *
 
 urlpatterns = patterns('',
     url(r'^artists/$', ArtistListView.as_view(), name="festival-artist-list"),
-    url(r'^artists/(?P<pk>.*)/$', ArtistDetailView.as_view(), name="festival-artist-detail"),
-    url(r'^videos/$', ArtistListView.as_view(), name="festival-video-list"),
-    url(r'^videos/(?P<pk>.*)/$', ArtistDetailView.as_view(), name="festival-video-detail"),
+    url(r'^artists/(?P<slug>.*)/$', ArtistDetailView.as_view(), name="festival-artist-detail"),
+    url(r'^videos/$', VideoListView.as_view(), name="festival-video-list"),
+    url(r'^videos/(?P<slug>.*)/$', VideoDetailView.as_view(), name="festival-video-detail"),
 
 )
index defac746451ef2e76ad91480e498e94539b291cc..7abd16b5c63799b1a99c79a1a0c75491963358ae 100644 (file)
@@ -1,10 +1,18 @@
 from django.shortcuts import render
 from django.views.generic import *
 from django.views.generic.base import *
+from django.shortcuts import get_object_or_404
 
 from festival.models import *
 
 
+class SlugMixin(object):
+
+    def get_object(self):
+        objects = self.model.objects.all()
+        return get_object_or_404(objects, slug=self.kwargs['slug'])
+
+
 class ArtistListView(ListView):
 
     model = Artist
@@ -15,7 +23,7 @@ class ArtistListView(ListView):
         return context
 
 
-class ArtistDetailView(DetailView):
+class ArtistDetailView(SlugMixin, DetailView):
 
     model = Artist
     template_name='festival/artist_detail.html'
@@ -36,7 +44,7 @@ class VideoListView(ListView):
         return context
 
 
-class VideoDetailView(DetailView):
+class VideoDetailView(SlugMixin, DetailView):
 
     model = Video
     template_name='festival/video_detail.html'
@@ -45,3 +53,4 @@ class VideoDetailView(DetailView):
     def get_context_data(self, **kwargs):
         context = super(VideoDetailView, self).get_context_data(**kwargs)
         return context
+