Commit c7a225e2 authored by Kroustouris Stauros's avatar Kroustouris Stauros Committed by Zenon Mousmoulas

Merge branch 'master' of https://github.com/grnet/djnro

Conflicts:
	djnro/templates/partial/footer.html
	edumanage/templatetags/template_maybe.py
parents fa3a5033 acdd52f4
{% load i18n %}
{% load template_exists %}
{% load template_maybe %}
<footer class="stickyfooter">
<div>
......@@ -16,7 +16,7 @@
Powered by <a href="http://djnro.grnet.gr/" target="_blank">DjNRO</a> v{{VERSION}}
{% if "partial/extra.footer.html"|template_exists %}
<div class="">
{% include "partial/extra.footer.html" %}
{% include_maybe "partial/extra.footer.html" %}
</div>
{% endif %}
</div>
......
from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()
@register.filter
@stringfilter
def template_exists(value):
try:
template.loader.get_template(value)
return True
except template.TemplateDoesNotExist:
return False
from django import template
from django.template.defaultfilters import stringfilter
from django.template.loader_tags import do_include
from django.template.defaulttags import CommentNode
register = template.Library()
@register.filter
@stringfilter
def template_exists(value):
try:
template.loader.get_template(value)
return True
except template.TemplateDoesNotExist:
return False
@register.tag('include_maybe')
def do_include_maybe(parser, token):
# Source: http://stackoverflow.com/a/18951166/15690
"Source: http://stackoverflow.com/a/18951166/15690"
bits = token.split_contents()
if len(bits) < 2:
raise template.TemplateSyntaxError(
......@@ -20,6 +33,7 @@ def do_include_maybe(parser, token):
return CommentNode()
_orig_render = silent_node.render
def wrapped_render(*args, **kwargs):
try:
return _orig_render(*args, **kwargs)
......
......@@ -6,6 +6,9 @@ import re
% if inst['type'] in (2, 3) and 'clients' in inst:
#{{{${' ' + inst['id'] if 'id' in inst else ''}
% for client in inst['clients']:
% if 'seen' in clients[client]:
# client ${client} defined previously
% else:
client ${client} {
secret = ${clients[client]['secret']}
<%
......@@ -21,6 +24,10 @@ ipaddr = re.split(r'/(?=[0-9]{1,2}$)', clients[client]['host'])
% endif
eduroamspco = GR
}
<%
clients[client]['seen'] = True
%>\
% endif
% endfor
#}}}
% endif
......
......@@ -31,6 +31,9 @@ for r in inst['realms']:
for srv in inst_servers:
</%doc>\
% for srv in set([s for r in inst['realms'] for s in inst['realms'][r]['proxy_to'] if 'proxy_to' in inst['realms'][r]]):
% if 'seen' in servers[srv]:
# server ${srv} defined previously
% else:
home_server ${srv} {
type = ${servers[srv]['rad_pkt_type']}
ipaddr = ${servers[srv]['host']}
......@@ -47,6 +50,10 @@ home_server ${srv} {
check_interval = 30
num_answers_to_alive = 3
}
<%
servers[srv]['seen'] = True
%>\
% endif
% endfor
% for realm in sorted([r for r in inst['realms'] if 'proxy_to' in inst['realms'][r]], cmp=wildcard_realm_least_precedence, reverse=True):
<%
......
......@@ -23,6 +23,9 @@ def wildcard_realm_least_precedence(a, b):
#{{{${' ' + inst['id'] if 'id' in inst else ''}
% if inst['type'] in (2, 3) and 'clients' in inst:
% for client in inst['clients']:
% if 'seen' in clients[client]:
# client ${client} defined previously
% else:
rewrite rewrite-${client}-sp {
include /etc/radsecproxy.conf.d/rewrite-default-sp.conf
% if 'id' in inst:
......@@ -40,6 +43,10 @@ client ${client} {
% endif
rewriteIn rewrite-${client}-sp
}
% endif
<%
clients[client]['seen'] = True
%>\
% endfor
% endif
% if inst['type'] in (1, 3) and 'realms' in inst:
......@@ -53,6 +60,9 @@ for r in inst['realms']:
for srv in inst_servers:
</%doc>\
% for srv in set([s for r in inst['realms'] for s in inst['realms'][r]['proxy_to'] if 'proxy_to' in inst['realms'][r]]):
% if 'seen' in servers[srv]:
# server ${srv} defined previously
% else:
rewrite rewrite-${srv}-idp {
include /etc/radsecproxy.conf.d/rewrite-default-idp.conf
}
......@@ -80,6 +90,10 @@ server ${srv}-acct {
rewriteIn rewrite-${srv}-idp
}
% endif
<%
servers[srv]['seen'] = True
%>\
% endif
% endfor
% for realm in sorted([r for r in inst['realms'] if 'proxy_to' in inst['realms'][r]], cmp=wildcard_realm_least_precedence, reverse=True):
realm ${realm | realm_regex} {
......
......@@ -37,7 +37,7 @@ class ServerDataReader:
if re.match(r"^https?://", self.src) is not None:
try:
resp = requests.get(src)
except ConnectionError:
except requests.ConnectionError:
exit_with_error("Connection failed for %s" % src)
if resp.status_code > 304 or not resp.ok:
exit_with_error("Fetch failed from %s" % src)
......
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 to comment