Add delete method for UserHostingKey

This commit is contained in:
PCoder 2019-04-28 23:13:54 +02:00
parent 1ccb4e9790
commit 71d1e6e3c9

View file

@ -212,6 +212,12 @@ class UserHostingKey(models.Model):
# self.save(update_fields=['public_key']) # self.save(update_fields=['public_key'])
return private_key, public_key return private_key, public_key
def delete(self,*args,**kwargs):
if os.path.isfile(self.private_key.path):
os.remove(self.private_key.path)
super(UserHostingKey, self).delete(*args,**kwargs)
class HostingBill(AssignPermissionsMixin, models.Model): class HostingBill(AssignPermissionsMixin, models.Model):
customer = models.ForeignKey(StripeCustomer) customer = models.ForeignKey(StripeCustomer)