forked from rc/aircox
		
	file moves...
This commit is contained in:
		@ -1,46 +0,0 @@
 | 
			
		||||
import copy
 | 
			
		||||
 | 
			
		||||
from django.contrib import admin
 | 
			
		||||
from django.utils.translation import ugettext as _, ugettext_lazy
 | 
			
		||||
from django.contrib.contenttypes.admin import GenericStackedInline
 | 
			
		||||
 | 
			
		||||
import aircox.programs.models as programs
 | 
			
		||||
from website.models import *
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def add_inline (base_model, post_model, prepend = False):
 | 
			
		||||
    class InlineModel (admin.StackedInline):
 | 
			
		||||
        model = post_model
 | 
			
		||||
        extra = 1
 | 
			
		||||
        max_num = 1
 | 
			
		||||
        verbose_name = _('Post')
 | 
			
		||||
 | 
			
		||||
        fieldsets = [
 | 
			
		||||
                (None, {
 | 
			
		||||
                    'fields': ['title', 'content', 'image', 'tags']
 | 
			
		||||
                }),
 | 
			
		||||
                (None, {
 | 
			
		||||
                    'fields': ['date', 'published', 'author', 'thread_pk', 'thread_type']
 | 
			
		||||
                })
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
    registry = admin.site._registry
 | 
			
		||||
    if not base_model in registry:
 | 
			
		||||
        raise TypeError(str(base_model) + " not in admin registry")
 | 
			
		||||
 | 
			
		||||
    inlines = list(registry[base_model].inlines) or []
 | 
			
		||||
    if prepend:
 | 
			
		||||
        inlines.insert(0, InlineModel)
 | 
			
		||||
    else:
 | 
			
		||||
        inlines.append(InlineModel)
 | 
			
		||||
 | 
			
		||||
    registry[base_model].inlines = inlines
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
add_inline(programs.Program, Program, True)
 | 
			
		||||
# add_inline(programs.Episode, Episode, True)
 | 
			
		||||
 | 
			
		||||
admin.site.register(Program)
 | 
			
		||||
# admin.site.register(Episode)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,50 +0,0 @@
 | 
			
		||||
import autocomplete_light.shortcuts as al
 | 
			
		||||
from aircox.programs.models import *
 | 
			
		||||
 | 
			
		||||
from taggit.models import Tag
 | 
			
		||||
al.register(Tag)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class OneFieldAutocomplete(al.AutocompleteModelBase):
 | 
			
		||||
    choice_html_format = u'''
 | 
			
		||||
        <span class="block" data-value="%s">%s</span>
 | 
			
		||||
    '''
 | 
			
		||||
 | 
			
		||||
    def choice_html (self, choice):
 | 
			
		||||
        value = choice[self.search_fields[0]]
 | 
			
		||||
        return self.choice_html_format % (self.choice_label(choice),
 | 
			
		||||
            self.choice_label(value))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def choices_for_request(self):
 | 
			
		||||
        #if not self.request.user.is_staff:
 | 
			
		||||
        #    self.choices = self.choices.filter(private=False)
 | 
			
		||||
        filter_args = { self.search_fields[0] + '__icontains': self.request.GET['q'] }
 | 
			
		||||
 | 
			
		||||
        self.choices = self.choices.filter(**filter_args)
 | 
			
		||||
        self.choices = self.choices.values(self.search_fields[0]).distinct()
 | 
			
		||||
        return self.choices
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TrackArtistAutocomplete(OneFieldAutocomplete):
 | 
			
		||||
    search_fields = ['artist']
 | 
			
		||||
    model = Track
 | 
			
		||||
 | 
			
		||||
al.register(TrackArtistAutocomplete)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TrackNameAutocomplete(OneFieldAutocomplete):
 | 
			
		||||
    search_fields = ['name']
 | 
			
		||||
    model = Track
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
al.register(TrackNameAutocomplete)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#class DiffusionAutocomplete(OneFieldAutocomplete):
 | 
			
		||||
#    search_fields = ['episode', 'program', 'start', 'stop']
 | 
			
		||||
#    model = Diffusion
 | 
			
		||||
#
 | 
			
		||||
#al.register(DiffusionAutocomplete)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,19 +0,0 @@
 | 
			
		||||
from django import forms
 | 
			
		||||
from django.contrib.admin import widgets
 | 
			
		||||
 | 
			
		||||
import autocomplete_light.shortcuts as al
 | 
			
		||||
from autocomplete_light.contrib.taggit_field import TaggitWidget
 | 
			
		||||
 | 
			
		||||
from aircox.programs.models import *
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TrackForm (forms.ModelForm):
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Track
 | 
			
		||||
        fields = ['artist', 'name', 'tags', 'position']
 | 
			
		||||
        widgets = {
 | 
			
		||||
            'artist': al.TextWidget('TrackArtistAutocomplete'),
 | 
			
		||||
            'name': al.TextWidget('TrackNameAutocomplete'),
 | 
			
		||||
            'tags': TaggitWidget('TagAutocomplete'),
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -1,22 +0,0 @@
 | 
			
		||||
from django.db import models
 | 
			
		||||
 | 
			
		||||
from aircox.cms.models import RelatedPost
 | 
			
		||||
import aircox.programs.models as programs
 | 
			
		||||
 | 
			
		||||
class Program (RelatedPost):
 | 
			
		||||
    class Relation:
 | 
			
		||||
        model = programs.Program
 | 
			
		||||
        bind_mapping = True
 | 
			
		||||
        mapping = {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
class Episode (RelatedPost):
 | 
			
		||||
    class Relation:
 | 
			
		||||
        model = programs.Diffusion
 | 
			
		||||
        bind_mapping = True
 | 
			
		||||
        mapping = {
 | 
			
		||||
            'thread': 'program',
 | 
			
		||||
            # 'title': 'name',
 | 
			
		||||
            # 'content': 'description',
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 15 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 41 KiB  | 
@ -1,130 +0,0 @@
 | 
			
		||||
 | 
			
		||||
body {
 | 
			
		||||
    background-color: #F2F2F2;
 | 
			
		||||
    font-family: "Myriad Pro",Calibri,Helvetica,Arial,sans-serif;
 | 
			
		||||
    margin: 0 3em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
h1, h2, h3 {
 | 
			
		||||
    font-family: "Myriad Pro",Calibri,Helvetica,Arial,sans-serif;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
time {
 | 
			
		||||
    font-size: 0.9em;
 | 
			
		||||
    color: #818181;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
a {
 | 
			
		||||
    text-decoration: none;
 | 
			
		||||
    color: #616161;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
a:hover {
 | 
			
		||||
    color: #818181;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** Menu **/
 | 
			
		||||
.menu {
 | 
			
		||||
    padding: 0.5em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    .menu_top {
 | 
			
		||||
        background-color: #212121;
 | 
			
		||||
        color: #007EDF;
 | 
			
		||||
        font-size: 1.1em;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    header.menu {
 | 
			
		||||
        padding: 0.2em;
 | 
			
		||||
        height: 9em;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        header.menu img {
 | 
			
		||||
            height: 100%;
 | 
			
		||||
            float: left;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #colony img {
 | 
			
		||||
            height: auto;
 | 
			
		||||
            position: fixed;
 | 
			
		||||
            top: 1em;
 | 
			
		||||
            right: 0;
 | 
			
		||||
            z-index: -1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    .menu h1 {
 | 
			
		||||
        font-size: 1.1em;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    .menu .post_list {
 | 
			
		||||
        font-size: 0.9em;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        .menu .post_list h3 {
 | 
			
		||||
            font-size: 1.0em;
 | 
			
		||||
            display: inline;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .menu .post_list time {
 | 
			
		||||
            margin: 0.2em;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** Page **/
 | 
			
		||||
.page-container {
 | 
			
		||||
    box-shadow: 0em 0.2em 0.5em 0.1em black;
 | 
			
		||||
    margin-bottom: 2em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.page {
 | 
			
		||||
    width: calc(100% - 0.4em);
 | 
			
		||||
    padding: 1.5em 0.2em;
 | 
			
		||||
    background-color: rgba(255, 255, 255, 0.8);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    .page img {
 | 
			
		||||
        box-shadow: 0em 0em 0.2em 0.01em black;
 | 
			
		||||
        border-radius: 0.2em;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
.post_list {
 | 
			
		||||
    padding: 0.1em;
 | 
			
		||||
    border: 1px #818181 dotted;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    .post_list.embed + nav {
 | 
			
		||||
        text-align: right;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    .post_list:not(.embed) + nav {
 | 
			
		||||
        text-align: center;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    main .post_list .post_item {
 | 
			
		||||
        min-height: 64px;
 | 
			
		||||
        padding: 0.2em;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    main .post_list .post_item:hover {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    main .post_list h3 {
 | 
			
		||||
        margin: 0.2em;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    main .post_list time {
 | 
			
		||||
        float: right;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    main .post_list img {
 | 
			
		||||
        float: left;
 | 
			
		||||
        margin-right: 0.5em;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,3 +0,0 @@
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
 | 
			
		||||
# Create your tests here.
 | 
			
		||||
@ -1,79 +0,0 @@
 | 
			
		||||
from django.conf.urls import url, include
 | 
			
		||||
 | 
			
		||||
from website.models import *
 | 
			
		||||
from website.views import *
 | 
			
		||||
 | 
			
		||||
from aircox.cms.models import Article
 | 
			
		||||
from aircox.cms.views import Menu, Section, Sections
 | 
			
		||||
from aircox.cms.routes import *
 | 
			
		||||
from aircox.cms.website import Website
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
website = Website(
 | 
			
		||||
    name = 'RadioCampus',
 | 
			
		||||
    styles = 'website/styles.css',
 | 
			
		||||
 | 
			
		||||
    menus = [
 | 
			
		||||
        Menu(
 | 
			
		||||
            position = 'header',
 | 
			
		||||
            sections = [
 | 
			
		||||
                Sections.Image(url = 'website/logo.png'),
 | 
			
		||||
                Sections.Image(url = 'website/colony.png', attrs = { 'id': 'colony' }),
 | 
			
		||||
            ]
 | 
			
		||||
        ),
 | 
			
		||||
 | 
			
		||||
        Menu(
 | 
			
		||||
            position = 'top',
 | 
			
		||||
            sections = [
 | 
			
		||||
                Section(content = "Radio Campus le SITE"),
 | 
			
		||||
            ]
 | 
			
		||||
        ),
 | 
			
		||||
 | 
			
		||||
        Menu(
 | 
			
		||||
            position = 'left',
 | 
			
		||||
            sections = [
 | 
			
		||||
                Section(content = 'loool<br>blob'),
 | 
			
		||||
                PreviousDiffusions(),
 | 
			
		||||
            ],
 | 
			
		||||
        ),
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
base_sections = [
 | 
			
		||||
    Sections.PostContent(),
 | 
			
		||||
    Sections.PostImage(),
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
base_routes =  [
 | 
			
		||||
    AllRoute,
 | 
			
		||||
    ThreadRoute,
 | 
			
		||||
    SearchRoute,
 | 
			
		||||
    DateRoute,
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
website.register(
 | 
			
		||||
    'article',
 | 
			
		||||
    Article,
 | 
			
		||||
    sections = base_sections,
 | 
			
		||||
    routes = base_routes
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
website.register(
 | 
			
		||||
    'program',
 | 
			
		||||
    Program,
 | 
			
		||||
    sections = base_sections + [
 | 
			
		||||
        ScheduleSection(),
 | 
			
		||||
        EpisodesSection(),
 | 
			
		||||
    ],
 | 
			
		||||
    routes = base_routes,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
website.register (
 | 
			
		||||
    'episode',
 | 
			
		||||
    Episode,
 | 
			
		||||
    sections = base_sections,
 | 
			
		||||
    routes = base_routes,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
urlpatterns = website.urls
 | 
			
		||||
 | 
			
		||||
@ -1,74 +0,0 @@
 | 
			
		||||
from django.shortcuts import render
 | 
			
		||||
from django.template.loader import render_to_string
 | 
			
		||||
from django.views.generic import ListView
 | 
			
		||||
from django.views.generic import DetailView
 | 
			
		||||
from django.core import serializers
 | 
			
		||||
from django.utils import timezone as tz
 | 
			
		||||
from django.utils.translation import ugettext as _, ugettext_lazy
 | 
			
		||||
 | 
			
		||||
import aircox.programs.models as programs
 | 
			
		||||
import aircox.cms.routes as routes
 | 
			
		||||
import aircox.cms.utils as utils
 | 
			
		||||
from aircox.cms.views import Sections
 | 
			
		||||
 | 
			
		||||
from website.models import *
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PlayListSection (Sections.List):
 | 
			
		||||
    title = _('Playlist')
 | 
			
		||||
 | 
			
		||||
    def get_object_list (self):
 | 
			
		||||
        tracks = programs.Track.objects \
 | 
			
		||||
                     .filter(episode = self.object) \
 | 
			
		||||
                     .order_by('position')
 | 
			
		||||
        return [ Sections.List.Item(None, track.title, track.artist)
 | 
			
		||||
                    for track in tracks ]
 | 
			
		||||
 | 
			
		||||
class ScheduleSection (Sections.List):
 | 
			
		||||
    title = _('Schedule')
 | 
			
		||||
 | 
			
		||||
    def get_object_list (self):
 | 
			
		||||
        scheds = programs.Schedule.objects \
 | 
			
		||||
                    .filter(program = self.object.pk)
 | 
			
		||||
 | 
			
		||||
        return [
 | 
			
		||||
            Sections.List.Item(None, sched.get_frequency_display(),
 | 
			
		||||
                             _('rerun') if sched.rerun else None)
 | 
			
		||||
            for sched in scheds
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
class EpisodesSection (Sections.Posts):
 | 
			
		||||
    title = _('Episodes')
 | 
			
		||||
 | 
			
		||||
    def get_object_list (self):
 | 
			
		||||
        return utils.filter_thread(Episode.objects, self.object)
 | 
			
		||||
 | 
			
		||||
    def get_url (self):
 | 
			
		||||
        return utils.get_url(self.website, routes.ThreadRoute, Episode,
 | 
			
		||||
                             { 'thread_model': 'program', 'pk': self.object.pk})
 | 
			
		||||
 | 
			
		||||
class PreviousDiffusions (Sections.Posts):
 | 
			
		||||
    title = _('Previous Diffusions')
 | 
			
		||||
    fields = ['title', 'time']
 | 
			
		||||
 | 
			
		||||
    def get_object_list (self):
 | 
			
		||||
        diffusions = programs.Diffusion.objects\
 | 
			
		||||
                         .filter(date__lt = tz.datetime.now())
 | 
			
		||||
        episodes = []
 | 
			
		||||
 | 
			
		||||
        for diffusion in diffusions:
 | 
			
		||||
            if not diffusion.episode:
 | 
			
		||||
                continue
 | 
			
		||||
 | 
			
		||||
            post = Episode.objects.filter(related = diffusion.episode.pk)
 | 
			
		||||
            if not post:
 | 
			
		||||
                continue
 | 
			
		||||
            post = post[0]
 | 
			
		||||
            post.date = diffusion.date
 | 
			
		||||
            episodes.append(post)
 | 
			
		||||
            if len(episodes) == self.paginate_by:
 | 
			
		||||
                break
 | 
			
		||||
        return episodes
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user