ALLES FÜR EINE FEUCHTE VAGINA

This commit is contained in:
holger.trampe 2019-12-12 21:13:13 +01:00
parent dc7da099d3
commit 6f2d0adfff
8 changed files with 22 additions and 11 deletions

View File

@ -21,9 +21,9 @@ var data = [
{ 'id': 'parent', 'role': "", 'name': 'Agentur {{request.user.profile.agency.name}}', 'color': '#71AF17', "imageUrl": ""},
{% for u in agencyuser %}
{% if u.profile.parent == u %}
{ 'id': '{{u.pk}}' , 'name': "{{u.first_name}} {{u.last_name}}",'role': '{{u.profile.get_func_display}}\n{{u.profile.compfunc}}', 'manager': 'parent', 'color': '#1859B7', "imageUrl": "{{u.profile.image.url}}", 'userid' : '{{u.pk}}' },
{ 'id': '{{u.pk}}' , 'name': "{{u.first_name}} {{u.last_name}}",'role': '{{u.profile.get_func_display}}\n{{u.profile.compfunc}}', 'manager': 'parent', 'color': '#1859B7', "imageUrl": "{{u.profile.image.get_photo_url}}", 'userid' : '{{u.pk}}' },
{% else %}
{ 'id': '{{u.pk}}', 'name': "{{u.first_name}} {{u.last_name}}", 'role': '{{u.profile.get_func_display}}\n{{u.profile.compfunc}}', 'manager': '{{u.profile.parent.pk}}', 'color': '#1859B7', "imageUrl": "{{u.profile.image.url }}", 'userid' : '{{u.pk}}'},
{ 'id': '{{u.pk}}', 'name': "{{u.first_name}} {{u.last_name}}", 'role': '{{u.profile.get_func_display}}\n{{u.profile.compfunc}}', 'manager': '{{u.profile.parent.pk}}', 'color': '#1859B7', "imageUrl": "{{u.profile.image.get_photo_url }}", 'userid' : '{{u.pk}}'},
{% endif %}
{% endfor %}
];

View File

@ -48,8 +48,7 @@
{% endfor %}
</tr>
</thead>
<tbody>
<tbody>
<tr>
{% for area in areas %}
<td class="text-center" style="background-color: rgba({{area.color.0}},{{area.color.1}},{{area.color.2}}, 0.3)">
@ -70,7 +69,6 @@
border-collapse: separate;
border-spacing: 25px 0px;
}
</style>
</div>
{% endblock content %}

View File

@ -31,7 +31,7 @@ class Agency(models.Model):
city = models.CharField(default="", max_length=200, blank=True)
email = models.EmailField(default="", blank=True)
phone = models.CharField(default="", max_length=20, blank=True)
agencypic = models.ImageField(default='default.jpg', upload_to='agencymain', blank=True)
agencypic = models.ImageField(default='default.jpg', upload_to='agencymain', blank=True, null="default.jpg")
def __str__(self):
return f'{self.name}'
@ -40,6 +40,13 @@ class Agency(models.Model):
def get_absolute_url(self):
return reverse('agency-update', kwargs={'pk':self.pk})
@property
def get_photo_url(self):
if self.agencypic and hasattr(self.agencypic, 'url'):
return self.agencypic.url
else:
return "/media/default.jpg"
'''
Class Profile
@ -77,7 +84,7 @@ class Profile(models.Model):
func = models.CharField(choices=agency_task, default="", max_length=50)
# Wenn dieses Profil gelöscht wird, wird NICHT die Agency geslöscht
agency = models.ForeignKey(Agency, on_delete=models.PROTECT)
image = models.ImageField(default='default.jpg', upload_to='userprofilepics', blank=True)
image = models.ImageField(default='default.jpg', upload_to='userprofilepics', blank=True, null="default.jpg")
compfunc = models.CharField(max_length=60, blank=True)
@ -106,6 +113,12 @@ class Profile(models.Model):
img = img.resize((wsize, baseheight), Image.ANTIALIAS)
img.save(self.image.path)
@property
def get_photo_url(self):
if self.image and hasattr(self.image, 'url'):
return self.image.url
else:
return "/media/default.jpg"
# PERMISSIONS - Über alle Modelle hinweg, in der url.py wird dann die route verhindert!
# Im template: if perms.users.PERMISSION

View File

@ -24,7 +24,7 @@
</p>
<h6><b>Agenturbild</b></h6>
<p>
<img class="img-profile" width="75%" src="{{ request.user.profile.agency.agencypic.url }}">
<img class="img-profile" width="75%" src="{{ request.user.profile.agency.agencypic.get_photo_url }}">
</p>
</div>
{% if perms.users.agency_change %}

View File

@ -34,7 +34,7 @@
<div class="card ml-2 mb-2 col-3">
<div class="card-body">
<img width="100%" src="{{ request.user.profile.agency.agencypic.url }}">
<img width="100%" src="{{ request.user.profile.get_photo_url }}">
</div>
</div>

View File

@ -3,7 +3,7 @@
{% block content %}
<div class="content-section">
<div class="media">
<img class="img-profile" width="17%" src="{{ user.profile.image.url }}">
<img class="img-profile " width="17%" src="{{ prof_user.profile.get_photo_url }}">
<div class="media-body col-5">
<h2 class="account-heading">Profil von {{ user.first_name }} {{ user.last_name }}</h2>
<hr>

View File

@ -3,7 +3,7 @@
{% block content %}
<div class="content-section">
<div class="media">
<img class="img-profile " width="17%" src="{{ prof_user.profile.image.url }}">
<img class="img-profile " width="17%" src="{{ prof_user.profile.get_photo_url }}">
<div class="media-body col-5">
<h2 class="account-heading">Profil von {{ prof_user.first_name }} {{ prof_user.last_name }}</h2>
<hr>