Revision 60441a7f

b/cloudcms/admin.py
33 33

  
34 34

  
35 35
from django.contrib import admin
36
from feincms.translations import admin_translationinline, short_language_code
37

  
36 38
from cloudcms import models
37 39

  
38 40

  
......
45 47
    raw_id_fields = ('logo',)
46 48
    extra = 1
47 49

  
50

  
48 51
class ClientAdmin(admin.ModelAdmin):
49 52
    inlines = [ClientVersionSourceAdminInline]
50 53

  
51 54

  
55
ServiceTranslationInline = admin_translationinline(models.ServiceTranslation,
56
        prepopulated_fields={'slug': ('title',)})
57

  
58
class ServiceAdmin(admin.ModelAdmin):
59
    inlines = [ServiceTranslationInline]
60

  
61

  
52 62
admin.site.register(models.Application, ApplicationAdmin)
53 63
admin.site.register(models.Client, ClientAdmin)
64
admin.site.register(models.Service, ServiceAdmin)
54 65

  
b/cloudcms/cms.py
158 158
Page.create_content_type(LoginForm)
159 159
Page.create_content_type(AboutBlock)
160 160
Page.create_content_type(ResourcesList)
161
Page.create_content_type(BlockColor) 
161
Page.create_content_type(BlockColor)
162 162

  
163 163

  
164 164

  
......
174 174
    from cloudcmsfaq.models import Question
175 175
    EXTRA_CONTENT_MODELS.append(Question)
176 176

  
177
if 'cloudcmsguide' in settings.INSTALLED_APPS:
178
    from cloudcmsguide.models import Section
179
    EXTRA_CONTENT_MODELS.append(Section)
180

  
177 181
for model in EXTRA_CONTENT_MODELS:
178 182
    # Feincms specific registrations for our blog entry model
179 183
    model.register_regions(
b/cloudcms/migrations/0009_auto__add_service__add_servicetranslation.py
1
# -*- coding: utf-8 -*-
2
import datetime
3
from south.db import db
4
from south.v2 import SchemaMigration
5
from django.db import models
6

  
7

  
8
class Migration(SchemaMigration):
9

  
10
    def forwards(self, orm):
11
        # Adding model 'Service'
12
        db.create_table('cloudcms_service', (
13
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
14
            ('ordering', self.gf('django.db.models.fields.SmallIntegerField')(default=0)),
15
        ))
16
        db.send_create_signal('cloudcms', ['Service'])
17

  
18
        # Adding model 'ServiceTranslation'
19
        db.create_table('cloudcms_servicetranslation', (
20
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
21
            ('parent', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', to=orm['cloudcms.Service'])),
22
            ('language_code', self.gf('django.db.models.fields.CharField')(default='en', max_length=10)),
23
            ('title', self.gf('django.db.models.fields.CharField')(max_length=100)),
24
            ('slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50)),
25
            ('description', self.gf('django.db.models.fields.CharField')(max_length=250, blank=True)),
26
            ('cms_page', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['page.Page'], null=True, blank=True)),
27
        ))
28
        db.send_create_signal('cloudcms', ['ServiceTranslation'])
29

  
30

  
31
    def backwards(self, orm):
32
        # Deleting model 'Service'
33
        db.delete_table('cloudcms_service')
34

  
35
        # Deleting model 'ServiceTranslation'
36
        db.delete_table('cloudcms_servicetranslation')
37

  
38

  
39
    models = {
40
        'cloudcms.application': {
41
            'Meta': {'object_name': 'Application'},
42
            'app_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
43
            'code': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
44
            'extra_styles': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
45
            'facebook_username': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
46
            'favicon': ('feincms.module.medialibrary.fields.MediaFileForeignKey', [], {'blank': 'True', 'related_name': "'as_favicon'", 'null': 'True', 'to': "orm['medialibrary.MediaFile']"}),
47
            'footer_bottom': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
48
            'footer_top': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
49
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
50
            'index_url': ('django.db.models.fields.CharField', [], {'default': "'/'", 'max_length': '255'}),
51
            'linked_in_username': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
52
            'logo': ('feincms.module.medialibrary.fields.MediaFileForeignKey', [], {'to': "orm['medialibrary.MediaFile']", 'null': 'True', 'blank': 'True'}),
53
            'show_twitter_feed_on_top': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
54
            'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['sites.Site']"}),
55
            'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
56
            'twitter_username': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
57
        },
58
        'cloudcms.client': {
59
            'Meta': {'object_name': 'Client'},
60
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
61
            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
62
            'uid': ('django.db.models.fields.CharField', [], {'max_length': '255'})
63
        },
64
        'cloudcms.clientversionsource': {
65
            'Meta': {'object_name': 'ClientVersionSource'},
66
            'architecture': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
67
            'client': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cloudcms.Client']"}),
68
            'file_regex': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
69
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
70
            'link': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
71
            'logo': ('feincms.module.medialibrary.fields.MediaFileForeignKey', [], {'to': "orm['medialibrary.MediaFile']", 'null': 'True', 'blank': 'True'}),
72
            'os': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
73
            'source_type': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
74
            'version_regex': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'})
75
        },
76
        'cloudcms.service': {
77
            'Meta': {'ordering': "['-ordering']", 'object_name': 'Service'},
78
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
79
            'ordering': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'})
80
        },
81
        'cloudcms.servicetranslation': {
82
            'Meta': {'ordering': "['title']", 'object_name': 'ServiceTranslation'},
83
            'cms_page': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['page.Page']", 'null': 'True', 'blank': 'True'}),
84
            'description': ('django.db.models.fields.CharField', [], {'max_length': '250', 'blank': 'True'}),
85
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
86
            'language_code': ('django.db.models.fields.CharField', [], {'default': "'en'", 'max_length': '10'}),
87
            'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'to': "orm['cloudcms.Service']"}),
88
            'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
89
            'title': ('django.db.models.fields.CharField', [], {'max_length': '100'})
90
        },
91
        'medialibrary.category': {
92
            'Meta': {'ordering': "['parent__title', 'title']", 'object_name': 'Category'},
93
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
94
            'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['medialibrary.Category']"}),
95
            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '150'}),
96
            'title': ('django.db.models.fields.CharField', [], {'max_length': '200'})
97
        },
98
        'medialibrary.mediafile': {
99
            'Meta': {'object_name': 'MediaFile'},
100
            'categories': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['medialibrary.Category']", 'null': 'True', 'blank': 'True'}),
101
            'copyright': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
102
            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
103
            'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}),
104
            'file_size': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
105
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
106
            'type': ('django.db.models.fields.CharField', [], {'max_length': '12'})
107
        },
108
        'page.page': {
109
            'Meta': {'ordering': "['tree_id', 'lft']", 'object_name': 'Page'},
110
            '_cached_url': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '300', 'db_index': 'True', 'blank': 'True'}),
111
            '_content_title': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
112
            '_page_title': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
113
            'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
114
            'creation_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
115
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
116
            'in_navigation': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
117
            'language': ('django.db.models.fields.CharField', [], {'default': "'en'", 'max_length': '10'}),
118
            'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
119
            'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
120
            'meta_description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
121
            'meta_keywords': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
122
            'modification_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
123
            'navigation_extension': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
124
            'override_url': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}),
125
            'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['page.Page']"}),
126
            'publication_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 7, 10, 0, 0)'}),
127
            'publication_end_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
128
            'redirect_to': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}),
129
            'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
130
            'site': ('django.db.models.fields.related.ForeignKey', [], {'default': '1', 'to': "orm['sites.Site']"}),
131
            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '150'}),
132
            'symlinked_page': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'page_page_symlinks'", 'null': 'True', 'to': "orm['page.Page']"}),
133
            'template_key': ('django.db.models.fields.CharField', [], {'default': "'twocolwide'", 'max_length': '255'}),
134
            'title': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
135
            'translation_of': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'translations'", 'null': 'True', 'to': "orm['page.Page']"}),
136
            'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
137
        },
138
        'sites.site': {
139
            'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"},
140
            'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
141
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
142
            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
143
        }
144
    }
145

  
146
    complete_apps = ['cloudcms']
b/cloudcms/models.py
36 36
from django.db import models
37 37
from django.conf import settings
38 38
from django.contrib.sites import models as sites_models
39
from django.utils.translation import ugettext_lazy as _, ugettext, ungettext
39 40
from django.core.cache import cache
40 41
from django.utils import simplejson
41 42

  
43
from feincms import translations
42 44
from feincms.module.medialibrary.fields import MediaFileForeignKey
43 45
from feincms.module.medialibrary.models import MediaFile
44 46

  
......
143 145
# hook for feincms configuration, is this appropriate place ??? who knows
144 146
from cloudcms.cms import *
145 147

  
148
class Service(models.Model, translations.TranslatedObjectMixin):
149
    """
150
    Service.
151
    """
152

  
153
    ordering = models.SmallIntegerField(_('ordering'), default=0)
154

  
155
    class Meta:
156
        verbose_name = _('service')
157
        verbose_name_plural = _('services')
158
        ordering = ['-ordering',]
159

  
160
    objects = translations.TranslatedObjectManager()
161

  
162
    def __unicode__(self):
163
        trans = translations.TranslatedObjectMixin.__unicode__(self)
164
        return trans or _('Unnamed category')
165

  
166

  
167
class ServiceTranslation(translations.Translation(Service)):
168
    """
169
    Service translation
170
    """
171
    title = models.CharField(_('service title'), max_length=100)
172
    slug = models.SlugField(_('slug'), unique=True)
173
    description = models.CharField(_('description'), max_length=250, blank=True)
174
    cms_page = models.ForeignKey(Page, null=True, blank=True)
175

  
176
    class Meta:
177
        verbose_name = _('service translation')
178
        verbose_name_plural = _('service translations')
179
        ordering = ['title']
180

  
181
    def __unicode__(self):
182
        return self.title
183

  
184
    def save(self, *args, **kwargs):
185
        if not self.slug:
186
            self.slug = slugify(self.title)
187

  
188
        super(ServiceTranslation, self).save(*args, **kwargs)
189

  
b/cloudcms/templatetags/cloudcms_tags.py
1
from django import template
2
from cloudcmsfaq.models import Question
3

  
4
register = template.Library()
5

  
6
@register.filter('get_service_faqs')
7
def get_service_faqs(service):
8
    """
9
    Retrun service faqs grouped by category
10
    """
11
    grouped = {}
12

  
13
    for q in Question.objects.active().filter(service=service, is_active=True):
14
        if q.category not in grouped:
15
            grouped[q.category] = []
16

  
17
        grouped[q.category].append(q)
18

  
19
    print grouped
20
    return grouped.iteritems()

Also available in: Unified diff