Change to fix issues with duplication hash check
WARNING: This will involve a minor migration. Fixing the hash value length on the model to be correct. Have made the hash function more sensible, and also not bound to the required field on actions. Needed for how stacktask-odoo handles dynamic required fields. gitignore updated as venv is needed to build migrations easily. Hashing now also properly supports actions with no set serializer. Change-Id: I12f3ad759aaab4c3796e11c359e1ebcbf3ef4e77
This commit is contained in:
parent
a092d099eb
commit
b6316e5965
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@
|
||||
stacktask.egg-info/*
|
||||
dist/*
|
||||
.tox/*
|
||||
env/*
|
||||
|
19
stacktask/api/migrations/0002_auto_20160815_2249.py
Normal file
19
stacktask/api/migrations/0002_auto_20160815_2249.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('api', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='task',
|
||||
name='hash_key',
|
||||
field=models.CharField(max_length=64, db_index=True),
|
||||
),
|
||||
]
|
@ -30,7 +30,7 @@ class Task(models.Model):
|
||||
"""
|
||||
uuid = models.CharField(max_length=32, default=hex_uuid,
|
||||
primary_key=True)
|
||||
hash_key = models.CharField(max_length=32, db_index=True)
|
||||
hash_key = models.CharField(max_length=64, db_index=True)
|
||||
|
||||
# who is this:
|
||||
ip_address = models.GenericIPAddressField()
|
||||
|
@ -148,8 +148,11 @@ def create_task_hash(task_type, action_list):
|
||||
|
||||
for action in action_list:
|
||||
hashable_list.append(action['name'])
|
||||
if not action['serializer']:
|
||||
continue
|
||||
# iterate like this to maintain consistent order for hash
|
||||
for field in action['action'].required:
|
||||
fields = sorted(action['serializer'].validated_data.keys())
|
||||
for field in fields:
|
||||
try:
|
||||
hashable_list.append(
|
||||
action['serializer'].validated_data[field])
|
||||
|
Loading…
Reference in New Issue
Block a user