mirror of
				https://github.com/StefBuwalda/dashboard_test.git
				synced 2025-10-31 03:39:58 +00:00 
			
		
		
		
	Added a function that turns a service instance into a dictionary.
This commit is contained in:
		
							
								
								
									
										12
									
								
								models.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								models.py
									
									
									
									
									
								
							| @@ -1,6 +1,7 @@ | ||||
| from mem import db | ||||
| from datetime import datetime, timezone | ||||
| from validators import url as is_url | ||||
| from typing import Any | ||||
|  | ||||
|  | ||||
| class log(db.Model): | ||||
| @@ -25,8 +26,19 @@ class service(db.Model): | ||||
|     ): | ||||
|         if not is_url(url): | ||||
|             raise Exception("URL IS NOT A VALID URL") | ||||
|         if len(label) > 15: | ||||
|             raise Exception("LABEL EXCEEDS MAXIMUM LENGTH (15)") | ||||
|         super().__init__() | ||||
|         self.url = url | ||||
|         self.label = label | ||||
|         self.public_access = public_access | ||||
|         self.ping_method = ping_method | ||||
|  | ||||
|     def to_dict(self) -> dict[str, Any]: | ||||
|         return { | ||||
|             "url": self.url, | ||||
|             "public_access": self.public_access, | ||||
|             "label": self.label, | ||||
|             "id": self.id, | ||||
|             "ping_method": self.ping_method, | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user