Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel work on the same report #191

Merged
merged 4 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/core/model/report_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,15 @@ def update_report_item(cls, id, data, user):

if 'attribute_id' in data:
for attribute in report_item.attributes:
if attribute.id == data['attribute_id']:
# sometime we compare: int & int or int & str
if str(attribute.id) == str(data['attribute_id']):
if attribute.value != data['attribute_value']:
modified = True
attribute.value = data['attribute_value']
data['attribute_value'] = ''
attribute.user = user
attribute.last_updated = datetime.now()
break
break

if 'add' in data:
if 'attribute_id' in data:
Expand All @@ -407,7 +408,8 @@ def update_report_item(cls, id, data, user):
if 'attribute_id' in data:
attribute_to_delete = None
for attribute in report_item.attributes:
if attribute.id == data['attribute_id']:
# sometime we compare: int & int or int & str
if str(attribute.id) == str(data['attribute_id']):
attribute_to_delete = attribute
break

Expand Down Expand Up @@ -466,7 +468,7 @@ def get_updated_data(cls, id, data):

if 'attribute_id' in data:
for attribute in report_item.attributes:
if attribute.id == data['attribute_id']:
if str(attribute.id) == data['attribute_id']:
data['attribute_value'] = attribute.value
data['attribute_last_updated'] = attribute.last_updated.strftime('%d.%m.%Y - %H:%M')
data['attribute_user'] = attribute.user.name
Expand All @@ -489,7 +491,7 @@ def get_updated_data(cls, id, data):

if 'attribute_id' in data:
for attribute in report_item.attributes:
if attribute.id == data['attribute_id']:
if str(attribute.id) == data['attribute_id']:
data['attribute_value'] = attribute.value
data['binary_mime_type'] = attribute.binary_mime_type
data['binary_size'] = attribute.binary_size
Expand Down
17 changes: 17 additions & 0 deletions src/gui/src/components/analyze/NewReportItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,15 @@ export default {
}
}
},

report_item_unlocked(data) {
if (this.edit === true && this.report_item.id === data.report_item_id) {
if (data.user_id !== this.$store.getters.getUserId) {
this.field_locks[data.field_id] = false
}
}
},

report_item_updated(data_info) {
if (this.edit === true && this.report_item.id === data_info.report_item_id) {
if (data_info.user_id !== this.$store.getters.getUserId) {
Expand All @@ -561,10 +563,24 @@ export default {
} else if (data.completed !== undefined) {
this.report_item.completed = data.completed
}
// if more users work on the same report -> update locked field with new value
if (data.update !== undefined) {
endLoop: for (let i = 0; i < this.attribute_groups.length; i++) {
for (let j = 0; j < this.attribute_groups[i].attribute_group_items.length; j++) {
for (let k = 0; k < this.attribute_groups[i].attribute_group_items[j].values.length; k++) {
if (this.attribute_groups[i].attribute_group_items[j].values[k].id == data.attribute_id) {
this.attribute_groups[i].attribute_group_items[j].values[k].value = data.attribute_value;
break endLoop;
}
}
}
}
}
})
}
}
},

showDetail(report_item) {
getReportItem(report_item.id).then((response) => {

Expand Down Expand Up @@ -755,6 +771,7 @@ export default {
}
return available;
},

importCSV() {
let csv_lines = this.csv.length;
let sorted_csv = new Array();
Expand Down
Loading