Commit 961a5f71 by Kálmán Viktor

network: use mixin in record create view to set owner

parent 338c3960
...@@ -495,21 +495,21 @@ class RecordCreate(LoginRequiredMixin, SuperuserRequiredMixin, ...@@ -495,21 +495,21 @@ class RecordCreate(LoginRequiredMixin, SuperuserRequiredMixin,
success_message = _(u'Successfully created record!') success_message = _(u'Successfully created record!')
def get_initial(self): def get_initial(self):
initial = super(RecordCreate, self).get_initial()
initial['domain'] = self.request.GET.get('domain')
host_pk = self.request.GET.get("host") host_pk = self.request.GET.get("host")
try: try:
host = Host.objects.get(pk=host_pk) host = Host.objects.get(pk=host_pk)
except (Host.DoesNotExist, ValueError): except (Host.DoesNotExist, ValueError):
host = None host = None
initial = {'owner': self.request.user}
if host: if host:
initial.update({ initial.update({
'type': "CNAME", 'type': "CNAME",
'host': host, 'host': host,
'address': host.get_fqdn(), 'address': host.get_fqdn(),
}) })
else:
initial['domain'] = self.request.GET.get('domain')
return initial return initial
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment