forked from openwisp/openwisp-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Added support for template tags openwisp#3
Closes openwisp#3
- Loading branch information
1 parent
0b11395
commit 26f3eb6
Showing
7 changed files
with
138 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
openwisp_controller/config/migrations/0003_template_tags.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.10.5 on 2017-04-21 13:46 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import taggit.managers | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('contenttypes', '0002_remove_content_type_name'), | ||
('config', '0002_config_settings_uuid'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='TaggedTemplate', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('object_id', models.UUIDField(db_index=True, verbose_name='Object id')), | ||
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='config_taggedtemplate_tagged_items', to='contenttypes.ContentType', verbose_name='Content type')), | ||
], | ||
options={ | ||
'verbose_name': 'Tagged item', | ||
'abstract': False, | ||
'verbose_name_plural': 'Tags', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='TemplateTag', | ||
fields=[ | ||
('name', models.CharField(max_length=100, unique=True, verbose_name='Name')), | ||
('slug', models.SlugField(max_length=100, unique=True, verbose_name='Slug')), | ||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
], | ||
options={ | ||
'verbose_name': 'Tag', | ||
'abstract': False, | ||
'verbose_name_plural': 'Tags', | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='taggedtemplate', | ||
name='tag', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='config_taggedtemplate_items', to='config.TemplateTag'), | ||
), | ||
migrations.AddField( | ||
model_name='template', | ||
name='tags', | ||
field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of template tags, may be used to ease auto configuration with specific settings (eg: 4G, mesh, WDS, VPN, ecc.)', through='config.TaggedTemplate', to='config.TemplateTag', verbose_name='Tags'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.test import TestCase | ||
|
||
from django_netjsonconfig.tests import CreateTemplateMixin | ||
from openwisp_users.tests.utils import TestOrganizationMixin | ||
|
||
from ..models import Template | ||
|
||
|
||
class TestTag(TestOrganizationMixin, CreateTemplateMixin, TestCase): | ||
""" | ||
tests for Tag model | ||
""" | ||
template_model = Template | ||
|
||
def test_tag(self): | ||
t = self._create_template(organization=self._create_org()) | ||
t.tags.add('mesh') | ||
self.assertEqual(t.tags.filter(name='mesh').count(), 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
django-netjsonconfig>=0.4.2,<0.6.0 | ||
django-netjsonconfig>=0.5.8,<0.7.0 | ||
openwisp-users<0.2 |