-
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 django viewflow with bpmn flow structure
- Loading branch information
Showing
16 changed files
with
488 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
# Register your models here. | ||
"""Add models to admin interface.""" | ||
|
||
from django.contrib import admin | ||
|
||
from building_dialouge_webapp.heat.models import Roof | ||
|
||
admin.site.register( | ||
[ | ||
Roof, | ||
], | ||
) |
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,28 @@ | ||
from viewflow import this | ||
from viewflow.workflow import act | ||
from viewflow.workflow import flow | ||
|
||
from . import views | ||
from .models import RoofProcess | ||
|
||
|
||
class RoofProcessFlow(flow.Flow): | ||
process_class = RoofProcess | ||
|
||
# Start the flow with the RoofTypeForm | ||
start = flow.Start(views.RoofTypeView.as_view()).Next(this.split_roof_type) | ||
|
||
# Split the flow based on roof_type selected | ||
split_roof_type = ( | ||
flow.If(act.process.is_flat_roof) | ||
.Then(this.roof_insulation) | ||
.Else(this.roof_details) | ||
) | ||
|
||
roof_insulation = flow.View(views.RoofInsulationView.as_view()).Next(this.end) | ||
|
||
roof_details = flow.View(views.RoofDetailsView.as_view()).Next(this.roof_usage) | ||
|
||
roof_usage = flow.View(views.RoofUsageView.as_view()).Next(this.roof_insulation) | ||
|
||
end = flow.End() |
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,29 @@ | ||
# Generated by Django 4.2.12 on 2024-09-09 15:06 | ||
|
||
from django.db import migrations, models | ||
import django_fsm | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Building', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('state', django_fsm.FSMField(default='start', max_length=50)), | ||
('roof_type', models.CharField(blank=True, choices=[('flachdach', 'Flachdach'), ('satteldach', 'Satteldach'), ('walmdach', 'Walmdach')], max_length=50, null=True)), | ||
('roof_area', models.FloatField(blank=True, null=True)), | ||
('roof_orientation', models.CharField(blank=True, max_length=100, null=True)), | ||
('number_roof_windows', models.IntegerField(blank=True, null=True)), | ||
('roof_usage', models.CharField(blank=True, max_length=100, null=True)), | ||
('roof_insulation_exists', models.BooleanField(blank=True, null=True)), | ||
('ventilation_system', models.CharField(blank=True, max_length=100, null=True)), | ||
], | ||
), | ||
] |
62 changes: 62 additions & 0 deletions
62
...ding_dialouge_webapp/heat/migrations/0002_remove_building_number_roof_windows_and_more.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,62 @@ | ||
# Generated by Django 4.2.12 on 2024-09-23 09:51 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django_fsm | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('heat', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='building', | ||
name='number_roof_windows', | ||
), | ||
migrations.RemoveField( | ||
model_name='building', | ||
name='roof_area', | ||
), | ||
migrations.RemoveField( | ||
model_name='building', | ||
name='roof_insulation_exists', | ||
), | ||
migrations.RemoveField( | ||
model_name='building', | ||
name='roof_orientation', | ||
), | ||
migrations.RemoveField( | ||
model_name='building', | ||
name='roof_type', | ||
), | ||
migrations.RemoveField( | ||
model_name='building', | ||
name='roof_usage', | ||
), | ||
migrations.RemoveField( | ||
model_name='building', | ||
name='ventilation_system', | ||
), | ||
migrations.AlterField( | ||
model_name='building', | ||
name='state', | ||
field=django_fsm.FSMField(choices=[('Bestandsaufnahme', 'Bestandsaufnahme'), ('Dach', 'Dach'), ('Dach_in_progress', 'Dach_in_progress'), ('Fenster', 'Fenster')], default=('Bestandsaufnahme', 'Bestandsaufnahme'), max_length=50), | ||
), | ||
migrations.CreateModel( | ||
name='Roof', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('roof_state', django_fsm.FSMField(choices=[('roof_type', 'roof_type'), ('roof_type_flach', 'roof_type_flach'), ('roof_type_walm', 'roof_type_walm'), ('roof_details', 'roof_details'), ('roof_insulation', 'roof_insulation'), ('ventilation_system', 'ventilation_system')], default=('roof_type', 'roof_type'), max_length=50)), | ||
('roof_type', models.CharField(blank=True, choices=[('flachdach', 'Flachdach'), ('satteldach', 'Satteldach'), ('walmdach', 'Walmdach')], max_length=50, null=True)), | ||
('roof_area', models.FloatField(blank=True, null=True)), | ||
('roof_orientation', models.CharField(blank=True, max_length=100, null=True)), | ||
('number_roof_windows', models.IntegerField(blank=True, null=True)), | ||
('roof_usage', models.CharField(blank=True, max_length=100, null=True)), | ||
('roof_insulation_exists', models.BooleanField(blank=True, null=True)), | ||
('building', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='heat.building')), | ||
], | ||
), | ||
] |
37 changes: 37 additions & 0 deletions
37
building_dialouge_webapp/heat/migrations/0003_roofprocess_remove_roof_building_and_more.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,37 @@ | ||
# Generated by Django 4.2.12 on 2024-10-15 15:22 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('viewflow_base', '__first__'), | ||
('heat', '0002_remove_building_number_roof_windows_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='RoofProcess', | ||
fields=[ | ||
], | ||
options={ | ||
'verbose_name_plural': 'Roof process', | ||
'proxy': True, | ||
'indexes': [], | ||
'constraints': [], | ||
}, | ||
bases=('viewflow_base.process',), | ||
), | ||
migrations.RemoveField( | ||
model_name='roof', | ||
name='building', | ||
), | ||
migrations.RemoveField( | ||
model_name='roof', | ||
name='roof_state', | ||
), | ||
migrations.DeleteModel( | ||
name='Building', | ||
), | ||
] |
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 +1,43 @@ | ||
# Create your models here. | ||
from django.db import models | ||
from viewflow.workflow.models import Process | ||
|
||
|
||
class Roof(models.Model): | ||
"""Model for roof.""" | ||
|
||
roof_type = models.CharField( | ||
max_length=50, | ||
choices=[ | ||
("flachdach", "Flachdach"), | ||
("satteldach", "Satteldach"), | ||
("walmdach", "Walmdach"), | ||
], | ||
blank=True, | ||
) | ||
roof_area = models.FloatField(blank=True) | ||
roof_orientation = models.CharField(max_length=100, blank=True) | ||
number_roof_windows = models.IntegerField(blank=True) | ||
roof_usage = models.CharField(max_length=100, blank=True) | ||
roof_insulation_exists = models.BooleanField(null=True, blank=True) | ||
|
||
def __str__(self): | ||
if self.pk: | ||
return f"#{self.roof_type}" | ||
return super().__str__() | ||
|
||
|
||
class RoofProcess(Process): | ||
""" | ||
This model extends the base viewflow `Process` model. | ||
""" | ||
|
||
class Meta: | ||
proxy = True | ||
verbose_name_plural = "Roof process" | ||
|
||
def is_flat_roof(self): | ||
try: | ||
return self.artifact.roof.roof_type == "Flachdach" | ||
except Roof.DoesNotExist: | ||
return None |
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
Oops, something went wrong.