Commit 693d71d9 authored by Jitka Novotna's avatar Jitka Novotna

ComponentList model

parent 53d3b473
...@@ -24,7 +24,7 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -24,7 +24,7 @@ from django.utils.translation import ugettext_lazy as _
from weblate.trans.models import ( from weblate.trans.models import (
Project, SubProject, Translation, Advertisement, Project, SubProject, Translation, Advertisement,
Unit, Suggestion, Comment, Check, Dictionary, Change, Unit, Suggestion, Comment, Check, Dictionary, Change,
Source, WhiteboardMessage, GroupACL Source, WhiteboardMessage, GroupACL, ComponentList,
) )
...@@ -228,6 +228,10 @@ class WhiteboardAdmin(admin.ModelAdmin): ...@@ -228,6 +228,10 @@ class WhiteboardAdmin(admin.ModelAdmin):
list_filter = ['project', 'language'] list_filter = ['project', 'language']
class ComponentListAdmin(admin.ModelAdmin):
list_display = ['title']
class AdvertisementAdmin(admin.ModelAdmin): class AdvertisementAdmin(admin.ModelAdmin):
list_display = ['placement', 'date_start', 'date_end', 'text'] list_display = ['placement', 'date_start', 'date_end', 'text']
search_fields = ['text', 'note'] search_fields = ['text', 'note']
...@@ -263,6 +267,7 @@ admin.site.register(SubProject, SubProjectAdmin) ...@@ -263,6 +267,7 @@ admin.site.register(SubProject, SubProjectAdmin)
admin.site.register(Advertisement, AdvertisementAdmin) admin.site.register(Advertisement, AdvertisementAdmin)
admin.site.register(WhiteboardMessage, WhiteboardAdmin) admin.site.register(WhiteboardMessage, WhiteboardAdmin)
admin.site.register(GroupACL, GroupACLAdmin) admin.site.register(GroupACL, GroupACLAdmin)
admin.site.register(ComponentList, ComponentListAdmin)
# Show some controls only in debug mode # Show some controls only in debug mode
if settings.DEBUG: if settings.DEBUG:
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trans', '0057_indexupdate_language_code'),
]
operations = [
migrations.CreateModel(
name='ComponentList',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.CharField(max_length=100)),
('components', models.ManyToManyField(to='trans.SubProject')),
],
options={
'verbose_name': 'Component list',
'verbose_name_plural': 'Component lists',
},
),
]
...@@ -38,6 +38,7 @@ from weblate.trans.models.group_acl import GroupACL ...@@ -38,6 +38,7 @@ from weblate.trans.models.group_acl import GroupACL
from weblate.trans.models.source import Source from weblate.trans.models.source import Source
from weblate.trans.models.advertisement import Advertisement from weblate.trans.models.advertisement import Advertisement
from weblate.trans.models.whiteboard import WhiteboardMessage from weblate.trans.models.whiteboard import WhiteboardMessage
from weblate.trans.models.componentlist import ComponentList
from weblate.trans.search import clean_search_unit from weblate.trans.search import clean_search_unit
from weblate.trans.signals import ( from weblate.trans.signals import (
vcs_post_push, vcs_post_update, vcs_pre_commit, vcs_post_commit, vcs_post_push, vcs_post_update, vcs_pre_commit, vcs_post_commit,
...@@ -51,7 +52,7 @@ from weblate.trans.scripts import ( ...@@ -51,7 +52,7 @@ from weblate.trans.scripts import (
__all__ = [ __all__ = [
'Project', 'SubProject', 'Translation', 'Unit', 'Check', 'Suggestion', 'Project', 'SubProject', 'Translation', 'Unit', 'Check', 'Suggestion',
'Comment', 'Vote', 'IndexUpdate', 'Change', 'Dictionary', 'Source', 'Comment', 'Vote', 'IndexUpdate', 'Change', 'Dictionary', 'Source',
'Advertisement', 'WhiteboardMessage', 'GroupACL', 'Advertisement', 'WhiteboardMessage', 'GroupACL', 'ComponentList',
] ]
......
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2015 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""Components list."""
from django.db import models
from django.core.exceptions import ValidationError
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
@python_2_unicode_compatible
class ComponentList(models.Model):
title = models.CharField(max_length=100)
components = models.ManyToManyField('SubProject')
def clean(self):
if not self.title:
raise ValidationError(_('Name must be specified'))
def __str__(self):
return self.title
class Meta(object):
verbose_name = _('Component list')
verbose_name_plural = _('Component lists')
...@@ -36,7 +36,7 @@ from django.core.exceptions import ValidationError ...@@ -36,7 +36,7 @@ from django.core.exceptions import ValidationError
from weblate.trans.models import ( from weblate.trans.models import (
Project, SubProject, Source, Unit, WhiteboardMessage, Check, Suggestion, Project, SubProject, Source, Unit, WhiteboardMessage, Check, Suggestion,
IndexUpdate, IndexUpdate, ComponentList,
get_related_units, get_related_units,
) )
from weblate import appsettings from weblate import appsettings
...@@ -953,6 +953,17 @@ class WhiteboardMessageTest(TestCase): ...@@ -953,6 +953,17 @@ class WhiteboardMessageTest(TestCase):
WhiteboardMessage() WhiteboardMessage()
class ComponentListTest(TestCase):
"""Test(s) for ComponentList model."""
def test_can_be_imported(self):
"""Test that ComponentList model can be imported.
Rather dumb test just to make sure there are no obvious parsing errors.
"""
ComponentList()
class ModelTestCase(RepoTestCase): class ModelTestCase(RepoTestCase):
def setUp(self): def setUp(self):
super(ModelTestCase, self).setUp() super(ModelTestCase, self).setUp()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment