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.
Added support to django-netjsonconfig 0.7.0
- Loading branch information
1 parent
140db7f
commit 2304479
Showing
5 changed files
with
65 additions
and
1 deletion.
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
25 changes: 25 additions & 0 deletions
25
openwisp_controller/pki/migrations/0002_add_organization_name.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,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.5 on 2017-11-03 15:47 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pki', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='ca', | ||
name='organization_name', | ||
field=models.CharField(blank=True, max_length=64, verbose_name='organization'), | ||
), | ||
migrations.AddField( | ||
model_name='cert', | ||
name='organization_name', | ||
field=models.CharField(blank=True, max_length=64, verbose_name='organization'), | ||
), | ||
] |
30 changes: 30 additions & 0 deletions
30
openwisp_controller/pki/migrations/0003_fill_organization_name.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,30 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def forward(apps, schema_editor): | ||
""" | ||
Fills the organization_name field of the following models: | ||
* ``openwisp_controller.pki.Ca`` | ||
* ``openwisp_controller.pki.Cert`` | ||
""" | ||
if not schema_editor.connection.alias == 'default': | ||
return | ||
from ..models import Ca, Cert | ||
|
||
for model in [Ca, Cert]: | ||
for obj in model.objects.all(): | ||
obj.organization_name = obj.x509.get_subject().organizationName or '' | ||
obj.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('pki', '0002_add_organization_name'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forward, reverse_code=migrations.RunPython.noop), | ||
] |
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.6.4,<0.7.0 | ||
django-netjsonconfig>=0.7.0,<0.8.0 | ||
openwisp-utils[users]<0.2 |