Method
create_law
(self, name: str, category: Category, level: str, publish_at: str = None, id=None)
Source from the content-addressed store, hash-verified
| 90 | Law.delete_by_id(id) |
| 91 | |
| 92 | def create_law(self, name: str, category: Category, level: str, publish_at: str = None, id=None) -> Law: |
| 93 | try: |
| 94 | params = { |
| 95 | "name": name, |
| 96 | } |
| 97 | if publish_at: |
| 98 | params["publish"] = publish_at |
| 99 | return Law.get(**params) |
| 100 | except Law.DoesNotExist: |
| 101 | pass |
| 102 | params = { |
| 103 | "name": name, |
| 104 | "category_id": category.id, |
| 105 | "level": level, |
| 106 | } |
| 107 | if publish_at: |
| 108 | params["publish"] = publish_at |
| 109 | if id: |
| 110 | params["id"] = id |
| 111 | return Law.create(**params) |
| 112 | |
| 113 | |
| 114 | def get_laws(): |
Tested by
no test coverage detected