Skip to content
Snippets Groups Projects
Verified Commit 5da86674 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Fix pictures.

parent 378dd0c6
No related branches found
No related tags found
No related merge requests found
......@@ -51,12 +51,16 @@ class TeckidsLdapMixin(object):
filename = '%s.jpg' % os.path.join(entry_dir, md5(field.encode("utf-8")).hexdigest())
if not getattr(self, field):
if getattr(self, field):
content = getattr(self, field)
else:
if fallback is None:
fallback = finders.find('people.jpg')
with open(fallback, 'rb') as fallback_file:
content = fallback_file.read()
with open(filename, 'wb') as image_file, open(fallback, 'rb') as fallback_file:
image_file.write(fallback_file.read())
with open(filename, 'wb') as image_file:
image_file.write(content)
return '%s/%s/%s/%s.jpg' % ('ticdesk', 'ldap', md5(self.dn.encode("utf-8")).hexdigest(), md5(field.encode("utf-8")).hexdigest())
......@@ -75,7 +79,7 @@ class TeckidsLdapMixin(object):
return self.get_image_rel(attr[:-5])
elif attr.endswith('__rel_latex'):
# FIXME Find a real solution for this
return '{%s}' % self.get_image_rel(attr[:-5])[:-4]
return '{%s}' % self.get_image_rel(attr[:-11])[:-4]
class TeckidsGroup(ldapdb.models.Model, TeckidsLdapMixin):
class Meta:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment