Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Commit

Permalink
[TemplatesVpnMixin] Added "get_default_templates" method
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Feb 10, 2017
1 parent 96f4d09 commit 066fe2a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions django_netjsonconfig/base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,16 @@ def save(self, *args, **kwargs):
created = self._state.adding
super(TemplatesVpnMixin, self).save(*args, **kwargs)
if created:
default = self.templates.model.objects.filter(default=True)
if default:
self.templates.add(*default)
default_templates = self.get_default_templates()
if default_templates:
self.templates.add(*default_templates)

def get_default_templates(self):
"""
retrieves default templates
may be redefined with a custom logic if needed
"""
return self.templates.model.objects.filter(default=True)

@classmethod
def get_templates_from_pk_set(cls, action, pk_set):
Expand Down

0 comments on commit 066fe2a

Please sign in to comment.