Base FAQ app
This commit is contained in:
parent
a5c7e99e46
commit
50ba30b7ba
|
@ -0,0 +1,17 @@
|
||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
# django
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# app
|
||||||
|
from .models import Question, TranslatedQuestion
|
||||||
|
|
||||||
|
|
||||||
|
class TranslatedQuestionInline(admin.TabularInline):
|
||||||
|
model = TranslatedQuestion
|
||||||
|
|
||||||
|
class QuestionAdmin(admin.ModelAdmin):
|
||||||
|
inlines = (TranslatedQuestionInline, )
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(Question, QuestionAdmin)
|
|
@ -0,0 +1,34 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Question',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TranslatedQuestion',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('title', models.CharField(max_length=256)),
|
||||||
|
('answer', models.TextField()),
|
||||||
|
('question', models.ForeignKey(to='faq.Question')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('manga', '0001_initial'),
|
||||||
|
('faq', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='translatedquestion',
|
||||||
|
name='language',
|
||||||
|
field=models.ForeignKey(default=1, to='manga.Language'),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,16 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class Question(models.Model):
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.translations.get(language__code='es').title
|
||||||
|
|
||||||
|
|
||||||
|
class TranslatedQuestion(models.Model):
|
||||||
|
question = models.ForeignKey(Question, related_name='translations')
|
||||||
|
language = models.ForeignKey('manga.Language')
|
||||||
|
title = models.CharField(max_length=256)
|
||||||
|
answer = models.TextField()
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.title
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
|
@ -69,6 +69,7 @@ INSTALLED_APPS = (
|
||||||
'shelfzilla.apps.mailing',
|
'shelfzilla.apps.mailing',
|
||||||
'shelfzilla.apps.manga',
|
'shelfzilla.apps.manga',
|
||||||
'shelfzilla.apps.blog',
|
'shelfzilla.apps.blog',
|
||||||
|
'shelfzilla.apps.faq',
|
||||||
'shelfzilla.apps.pjax',
|
'shelfzilla.apps.pjax',
|
||||||
|
|
||||||
# API
|
# API
|
||||||
|
|
Reference in New Issue