2
0
Fork 0

resend invite sms in admin backend, admin view improvements

This commit is contained in:
Andreas (@xAndy) Zimmermann 2022-04-21 00:53:53 +02:00
parent 972277ebcd
commit bf3b276e39
2 changed files with 20 additions and 3 deletions

View File

@ -19,10 +19,24 @@ class ShiftAdmin(admin.ModelAdmin):
return object.room.required_helpers - object.shiftregistration_set.count()
# admin.site.register(Shift)
def send_login(modeladmin, request, queryset):
for helper in queryset:
helper.send_confirmation()
class RegistationInline(admin.TabularInline):
model = ShiftRegistration
@admin.register(Helper)
class HelperAdmin(admin.ModelAdmin):
readonly_fields = ("phone",)
fields = ("name", "phone", "number_validated")
list_display = ("name",)
inlines = (RegistationInline,)
actions = (send_login,)
admin.site.register(Helper)
admin.site.register(ShiftRegistration)
admin.site.register(Message)
admin.site.register(LoginToken)

View File

@ -31,7 +31,7 @@ class Shift(models.Model):
class Helper(models.Model):
# todo: add propper phone number validation, maybe even country code?
phone = models.CharField(max_length=200, primary_key=True)
phone = models.CharField(max_length=200, primary_key=True, editable=False)
name = models.CharField(max_length=200)
# change this to a generic state variable to allow for number blocking/account deactivation?
number_validated = models.BooleanField(default=False)
@ -86,6 +86,9 @@ class ShiftRegistration(models.Model):
shift__start_at__lte=timezone.now() + timedelta(minutes=60),
)
def __str__(self):
return f"{self.helper.name}: {self.shift}"
class Message(models.Model):
# remove limit and send long messages in multiple messages?