Browse Source

Fix "unique" rule on items

theenglishway (time) 6 năm trước cách đây
mục cha
commit
6d857357b2
2 tập tin đã thay đổi với 9 bổ sung5 xóa
  1. 8 5
      planner/models/items.py
  2. 1 0
      planner/validator.py

+ 8 - 5
planner/models/items.py

@@ -39,11 +39,6 @@ class Item(TemplateMixin, SchemaMixin, DbMixin):
         name:
             required: true
             type: string
-            is_unique_with: 
-                table: sprint
-                fields:
-                  - milestone_id
-                  - sprint_id
         description:
             required: true
             type: string
@@ -77,10 +72,18 @@ class Item(TemplateMixin, SchemaMixin, DbMixin):
             is_fk: milestone
             excludes: sprint_id
             required: true
+            is_unique_with: 
+                table: item
+                fields:
+                  - name
         sprint_id:
             is_fk: sprint
             excludes: milestone_id
             required: true
+            is_unique_with: 
+                table: item
+                fields:
+                  - name
         date_added:
             type: datetime
             default_setter: utcnow

+ 1 - 0
planner/validator.py

@@ -36,6 +36,7 @@ class DbValidator(Validator):
 
         table = self.db.table(defs['table'])
         all_fields = field, *defs['fields']
+
         if table.search(make_query(*all_fields)):
             self._error(
                 field,