Code cleanups
PEP8 cleanups. Add keyword arguments. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-03-25 04:47
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-06-03 18:26
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
@@ -8,8 +6,10 @@ from django.utils.text import slugify
|
||||
from mayan.apps.common.validators import validate_internal_name
|
||||
|
||||
|
||||
def generate_internal_name(apps, schema_editor):
|
||||
Workflow = apps.get_model('document_states', 'Workflow')
|
||||
def operation_generate_internal_name(apps, schema_editor):
|
||||
Workflow = apps.get_model(
|
||||
app_label='document_states', model_name='Workflow'
|
||||
)
|
||||
internal_names = []
|
||||
|
||||
for workflow in Workflow.objects.using(schema_editor.connection.alias).all():
|
||||
@@ -50,7 +50,8 @@ class Migration(migrations.Migration):
|
||||
|
||||
# Generate the slugs based on the labels
|
||||
migrations.RunPython(
|
||||
generate_internal_name, reverse_code=migrations.RunPython.noop
|
||||
code=operation_generate_internal_name,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
|
||||
# Make the internal name field unique
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-08-03 06:38
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
@@ -17,8 +15,19 @@ class Migration(migrations.Migration):
|
||||
migrations.CreateModel(
|
||||
name='WorkflowTransitionTriggerEvent',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('stored_event_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='trigger_events', to='events.EventType', verbose_name='Event type')),
|
||||
(
|
||||
'id', models.AutoField(
|
||||
auto_created=True, primary_key=True, serialize=False,
|
||||
verbose_name='ID'
|
||||
)
|
||||
),
|
||||
(
|
||||
'stored_event_type', models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name='trigger_events', to='events.EventType',
|
||||
verbose_name='Event type'
|
||||
)
|
||||
),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Workflow transition trigger event',
|
||||
@@ -28,16 +37,29 @@ class Migration(migrations.Migration):
|
||||
migrations.AddField(
|
||||
model_name='workflowtransition',
|
||||
name='trigger_time_period',
|
||||
field=models.PositiveIntegerField(blank=True, help_text='Amount of time after which this transition will trigger on its own.', null=True, verbose_name='Trigger time period'),
|
||||
field=models.PositiveIntegerField(
|
||||
blank=True, help_text='Amount of time after which this '
|
||||
'transition will trigger on its own.', null=True,
|
||||
verbose_name='Trigger time period'
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='workflowtransition',
|
||||
name='trigger_time_unit',
|
||||
field=models.CharField(blank=True, choices=[('days', 'Days'), ('hours', 'Hours'), ('minutes', 'Minutes')], max_length=8, null=True, verbose_name='Trigger time unit'),
|
||||
field=models.CharField(
|
||||
blank=True, choices=[
|
||||
('days', 'Days'), ('hours', 'Hours'),
|
||||
('minutes', 'Minutes')
|
||||
], max_length=8, null=True, verbose_name='Trigger time unit'
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='workflowtransitiontriggerevent',
|
||||
name='transition',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='document_states.WorkflowTransition', verbose_name='Transition'),
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to='document_states.WorkflowTransition',
|
||||
verbose_name='Transition'
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-08-03 06:51
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-08-03 07:28
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
@@ -17,16 +15,28 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='workflowinstancelogentry',
|
||||
name='user',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User'),
|
||||
field=models.ForeignKey(
|
||||
blank=True, null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL, verbose_name='User'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='workflowtransitiontriggerevent',
|
||||
name='event_type',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.EventType', verbose_name='Event type'),
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to='events.EventType', verbose_name='Event type'
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='workflowtransitiontriggerevent',
|
||||
name='transition',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='trigger_events', to='document_states.WorkflowTransition', verbose_name='Transition'),
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name='trigger_events',
|
||||
to='document_states.WorkflowTransition',
|
||||
verbose_name='Transition'
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-08-03 07:52
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-08-07 06:12
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
@@ -16,13 +14,49 @@ class Migration(migrations.Migration):
|
||||
migrations.CreateModel(
|
||||
name='WorkflowStateAction',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('label', models.CharField(max_length=255, verbose_name='Label')),
|
||||
('enabled', models.BooleanField(default=True, verbose_name='Enabled')),
|
||||
('when', models.PositiveIntegerField(choices=[(1, 'On entry'), (2, 'On exit')], default=1, help_text='At which moment of the state this action will execute', verbose_name='When')),
|
||||
('action_path', models.CharField(help_text='The dotted Python path to the workflow action class to execute.', max_length=128, verbose_name='Entry action path')),
|
||||
('action_data', models.TextField(blank=True, verbose_name='Entry action data')),
|
||||
('state', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='actions', to='document_states.WorkflowState', verbose_name='Workflow state')),
|
||||
(
|
||||
'id', models.AutoField(
|
||||
auto_created=True, primary_key=True, serialize=False,
|
||||
verbose_name='ID'
|
||||
)
|
||||
),
|
||||
(
|
||||
'label', models.CharField(
|
||||
max_length=255, verbose_name='Label'
|
||||
)
|
||||
),
|
||||
(
|
||||
'enabled', models.BooleanField(
|
||||
default=True, verbose_name='Enabled'
|
||||
)
|
||||
),
|
||||
(
|
||||
'when', models.PositiveIntegerField(
|
||||
choices=[(1, 'On entry'), (2, 'On exit')], default=1,
|
||||
help_text='At which moment of the state this action '
|
||||
'will execute', verbose_name='When'
|
||||
)
|
||||
),
|
||||
(
|
||||
'action_path', models.CharField(
|
||||
help_text='The dotted Python path to the workflow '
|
||||
'action class to execute.', max_length=128,
|
||||
verbose_name='Entry action path'
|
||||
)
|
||||
),
|
||||
(
|
||||
'action_data', models.TextField(
|
||||
blank=True, verbose_name='Entry action data'
|
||||
)
|
||||
),
|
||||
(
|
||||
'state', models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name='actions',
|
||||
to='document_states.WorkflowState',
|
||||
verbose_name='Workflow state'
|
||||
)
|
||||
),
|
||||
],
|
||||
options={
|
||||
'ordering': ('label',),
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.10 on 2018-03-10 17:17
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
@@ -14,6 +12,10 @@ class Migration(migrations.Migration):
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='workflowinstancelogentry',
|
||||
options={'ordering': ('datetime',), 'verbose_name': 'Workflow instance log entry', 'verbose_name_plural': 'Workflow instance log entries'},
|
||||
options={
|
||||
'ordering': ('datetime',),
|
||||
'verbose_name': 'Workflow instance log entry',
|
||||
'verbose_name_plural': 'Workflow instance log entries'
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.10 on 2018-03-15 00:29
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
@@ -14,6 +12,9 @@ class Migration(migrations.Migration):
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='workflowinstance',
|
||||
options={'ordering': ('workflow',), 'verbose_name': 'Workflow instance', 'verbose_name_plural': 'Workflow instances'},
|
||||
options={
|
||||
'ordering': ('workflow',), 'verbose_name': 'Workflow instance',
|
||||
'verbose_name_plural': 'Workflow instances'
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.11 on 2018-08-23 23:53
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
@@ -15,6 +13,9 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='workflowstateaction',
|
||||
name='label',
|
||||
field=models.CharField(help_text='A simple identifier for this action.', max_length=255, verbose_name='Label'),
|
||||
field=models.CharField(
|
||||
help_text='A simple identifier for this action.',
|
||||
max_length=255, verbose_name='Label'
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -4,18 +4,26 @@ from django.db import migrations
|
||||
|
||||
|
||||
def operation_add_full_path(apps, schema_editor):
|
||||
WorkflowStateAction = apps.get_model('document_states', 'WorkflowStateAction')
|
||||
WorkflowStateAction = apps.get_model(
|
||||
app_label='document_states', model_name='WorkflowStateAction'
|
||||
)
|
||||
|
||||
for workflow_state_action in WorkflowStateAction.objects.using(schema_editor.connection.alias).all():
|
||||
workflow_state_action.action_path = 'mayan.apps.{}'.format(workflow_state_action.action_path)
|
||||
workflow_state_action.action_path = 'mayan.apps.{}'.format(
|
||||
workflow_state_action.action_path
|
||||
)
|
||||
workflow_state_action.save()
|
||||
|
||||
|
||||
def operation_remove_full_path(apps, schema_editor):
|
||||
WorkflowStateAction = apps.get_model('document_states', 'WorkflowStateAction')
|
||||
WorkflowStateAction = apps.get_model(
|
||||
app_label='document_states', model_name='WorkflowStateAction'
|
||||
)
|
||||
|
||||
for workflow_state_action in WorkflowStateAction.objects.using(schema_editor.connection.alias).all():
|
||||
workflow_state_action.action_path = workflow_state_action.action_path.replace('mayan.apps.', '')
|
||||
workflow_state_action.action_path = workflow_state_action.action_path.replace(
|
||||
'mayan.apps.', ''
|
||||
)
|
||||
workflow_state_action.save()
|
||||
|
||||
|
||||
@@ -27,6 +35,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
operation_add_full_path, reverse_code=operation_remove_full_path
|
||||
code=operation_add_full_path,
|
||||
reverse_code=operation_remove_full_path
|
||||
)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user