def utilization(user, ressource): domains = get_domains(user) if ressource == 'accounts': return VHost.objects.filter(domain__in=list(domains)).count() if ressource == 'redirects': return HTTPRedirect.objects.filter(domain__in=list(domains)).count() return None
def utilization(user, ressource): """Returns the correct ressource.""" domains = get_domains(user) if ressource == 'accounts': return Account.objects.filter(domain__in=list(domains)).count() if ressource == 'redirects': return Redirect.objects.filter(domain__in=list(domains)).count() return None
def redirect_list(request): """List all mail redirects. :param request: the request object :returns: a list of mail redirects """ domains = get_domains(request.user) return object_list(request, Redirect.objects.filter(domain__in = domains), template_name='limeade_mail/redirect_list.html')
def utilization(user, ressource): """Filters specific ressources.""" domains = get_domains(user) if ressource == 'accounts': return VHost.objects.filter(domain__in=list(domains)).count() if ressource == 'redirects': return HTTPRedirect.objects.filter( domain__in=list(domains)).count() return None
def vhost_list(request): """List of web-vhosts. :param request: the request object :returns: list of web vhosts """ domains = get_domains(request.user) return object_list(request, VHost.objects.filter(domain__in = domains), template_name='limeade_web/vhost_list.html')
def account_list(request): """List all mail accounts of a user. :param request: the request object :returns: a list of mail accounts """ domains = get_domains(request.user) return object_list(request, Account.objects.filter(domain__in = domains), template_name='limeade_mail/account_list.html')
def redirect_add(request): "Create a new mail redirect" form = RedirectForm(request.POST or None) form.fields['domain'].queryset = get_domains(request.user) if form.is_valid(): form.save() return redirect('limeade_mail_redirect_list') return render_to_response("limeade_mail/redirect_add.html", {"form": form}, context_instance = RequestContext(request))
def redirect_edit(request, slug): "Edit a HTTP redirect" r = Redirect.objects.get(pk=slug) form = RedirectForm(request.POST or None, instance=r) form.fields['domain'].queryset = get_domains(request.user) if form.is_valid(): form.save() return redirect('limeade_web_redirect_list') return render_to_response("limeade_web/redirect_edit.html", {"form": form}, context_instance = RequestContext(request))
def vhost_list(request): """List of web-vhosts. :param request: the request object :returns: list of web vhosts """ domains = get_domains(request.user) return object_list(request, VHost.objects.filter(domain__in=domains), template_name='limeade_web/vhost_list.html')
def account_add(request): "Add a new mail account" form = AccountForm(request.POST or None) form.fields['domain'].queryset = get_domains(request.user) if form.is_valid(): ac = form.save(commit=False) ac.set_password(form.cleaned_data['password']) ac.save() return redirect('limeade_mail_account_list') return render_to_response("limeade_mail/account_add.html", {"form": form}, context_instance = RequestContext(request))
def redirect_add(request): """Create a new mail redirect. :param request: the request object :returns: an edit form template """ form = RedirectForm(request.POST or None) form.fields['domain'].queryset = get_domains(request.user) if form.is_valid(): form.save() return redirect('limeade_mail_redirect_list') return render_to_response("limeade_mail/redirect_add.html", {"form": form}, context_instance = RequestContext(request))
def vhost_add(request): """Create a new web-vhost. :param request: the request object :returns: an edit form template """ form = VHostForm(request.POST or None) form.fields['domain'].queryset = get_domains(request.user) if form.is_valid(): form.save() return redirect('limeade_web_vhost_list') return render_to_response("limeade_web/vhost_add.html", {"form": form}, context_instance = RequestContext(request))
def account_add(request): """Add a new mail account. :param request: the request object :returns: an edit form template """ form = AccountForm(request.POST or None) form.fields['domain'].queryset = get_domains(request.user) if form.is_valid(): ac = form.save(commit=False) ac.set_password(form.cleaned_data['password']) ac.save() return redirect('limeade_mail_account_list') return render_to_response("limeade_mail/account_add.html", {"form": form}, context_instance = RequestContext(request))
def redirect_edit(request, slug): """Edit a HTTP redirect. :param request: the request object :param slug: the id of the redirect :returns: an edit form template """ r = Redirect.objects.get(pk=slug) form = RedirectForm(request.POST or None, instance=r) form.fields['domain'].queryset = get_domains(request.user) if form.is_valid(): form.save() return redirect('limeade_web_redirect_list') return render_to_response("limeade_web/redirect_edit.html", {"form": form}, context_instance=RequestContext(request))
def redirect_edit(request, slug): """Edit a mail redirect. :param request: the request object :param slug: the id of the redirect :returns: an edit form template """ r = Redirect.objects.get(pk=slug) if r.domain.owner() != request.user: return redirect('limeade_mail_redirect_list') form = RedirectForm(request.POST or None, instance=r) form.fields['domain'].queryset = get_domains(request.user) if form.is_valid(): form.save() return redirect('limeade_mail_redirect_list') return render_to_response("limeade_mail/redirect_edit.html", {"form": form}, context_instance = RequestContext(request))
def redirect_list(request): "List all mail redirects" domains = get_domains(request.user) return object_list(request, Redirect.objects.filter(domain__in = domains), template_name='limeade_mail/redirect_list.html')
def account_list(request): "List all mail accounts of a user" domains = get_domains(request.user) return object_list(request, Account.objects.filter(domain__in = domains), template_name='limeade_mail/account_list.html')
def get_vhosts(user): """Returns all vhosts that belongs to one user.""" return VHost.objects.filter(domain__in=list(get_domains(user)))
def get_vhosts(user): return VHost.objects.filter(domain__in=list(get_domains(user)))