Refactor and enhance device management and authentication features
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 4m12s

- Updated the `reverse_dhivehi_string` function to correct the range for combining characters.
- Added new device handling in the health check view and integrated the `add_new_devices_to_omada` task.
- Improved date handling in `CreateTemporaryUserView` to ensure proper string conversion.
- Enhanced OTP sending by converting mobile numbers to strings.
- Implemented MAC address validation in the `Device` model using a custom validator.
- Removed unnecessary fields from the `CreateDeviceSerializer`.
- Normalized MAC address format in the `DeviceListCreateAPIView`.
- Updated the `djangopasswordlessknox` package to improve code consistency and readability.
- Added migration to enforce MAC address validation in the database.
This commit is contained in:
2025-04-25 14:37:27 +05:00
parent 0f19f0c15c
commit 83db42cc60
24 changed files with 475 additions and 209 deletions

View File

@ -33,9 +33,14 @@ class AbstractBaseCallbackToken(models.Model):
When a new token is created, older ones of the same type are invalidated
via the pre_save signal in signals.py.
"""
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
id = models.UUIDField(
primary_key=True, default=uuid.uuid4, editable=False, unique=True
)
created_at = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name=None, on_delete=models.CASCADE)
user = models.ForeignKey(
settings.AUTH_USER_MODEL, related_name=None, on_delete=models.CASCADE
)
is_active = models.BooleanField(default=True)
to_alias = models.CharField(blank=True, max_length=40)
to_alias_type = models.CharField(blank=True, max_length=20)
@ -44,9 +49,9 @@ class AbstractBaseCallbackToken(models.Model):
class Meta:
abstract = True
get_latest_by = 'created_at'
ordering = ['-id']
unique_together = (('key', 'is_active'),)
get_latest_by = "created_at"
ordering = ["-id"]
unique_together = (("key", "is_active"),)
def __str__(self):
return str(self.key)
@ -56,7 +61,8 @@ class CallbackToken(AbstractBaseCallbackToken):
"""
Generates a random six digit number to be returned.
"""
key = models.CharField(default=generate_numeric_token, max_length=6, unique=True)
class Meta(AbstractBaseCallbackToken.Meta):
verbose_name = 'Callback Token'
verbose_name = "Callback Token"