Added markdown description for challenges and profile info

This commit is contained in:
teras 2017-12-02 21:24:54 +02:00 committed by Lauri Võsandi
parent c13b0c7971
commit 9e5a795295
3 changed files with 61 additions and 25 deletions

View File

@ -17,6 +17,8 @@ def get_inventory_item_path(filename):
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
icon = models.ImageField(upload_to=get_profile_image_path, default='default_icon.png')
phone_number = models.CharField(max_length=16, blank=True, null=True)
contact_info = models.TextField(blank=True, null=True)
def __str__(self):
return self.user.username
@ -35,7 +37,7 @@ class Challenge(models.Model):
id = models.AutoField(primary_key=True)
creator = models.ForeignKey(User, blank=True, null=True, editable=False, on_delete=models.SET_NULL)
name = models.CharField(max_length=256)
description = models.TextField(blank=True)
description = models.TextField(blank=True, null=True)
tags = models.ManyToManyField(ChallengeTag, blank=True)
def __str__(self):

View File

@ -35,6 +35,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'location_field.apps.DefaultConfig',
'markdownify',
'kspace'
]
@ -80,6 +81,20 @@ DATABASES = {
}
}
MARKDOWNIFY_WHITELIST_TAGS = [
'a',
'abbr',
'acronym',
'b',
'blockquote',
'em',
'i',
'li',
'ol',
'p',
'strong',
'ul'
]
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

View File

@ -1,4 +1,7 @@
{% extends 'base.html' %}
{% load markdownify %}
{% block content %}
<div class="row container">
<div class="row">
@ -11,44 +14,60 @@
{% endfor %}
</div>
<p style="">{{ challenge.description }}
</p>
<p style="">{{ challenge.description | markdownify }}</p>
<div class="section">
<p>I am usually at k-space on weekends. Come and take a look.</p>
<div class="valign-wrapper"><i class="material-icons">email</i>&nbsp; eric.cartman@email.com</div>
{% if challenge.creator.profile.contact_info %}
<p>{{ challenge.creator.profile.contact_info }}</p>
{% endif %}
{% if challenge.creator.email %}
<div class="valign-wrapper"><i class="material-icons">email</i>&nbsp;{{ challenge.creator.email }}</div>
<br>
<div class="valign-wrapper"><i class="material-icons">phone</i>&nbsp;55 55 5555</div>
{% endif %}
{% if challenge.creator.profile.phone_number %}
<div class="valign-wrapper"><i class="material-icons">phone</i>&nbsp;{{ challenge.creator.profile.phone_number }}</div>
{% endif %}
</div>
</div>
<div class="col m4">
<ul class="collection">
<li class="collection-item avatar">
<img src="https://vignette.wikia.nocookie.net/southpark/images/0/0d/1a.jpg/revision/latest/scale-to-width-down/310?cb=20100826182516"
<img src="/media/{{ challenge.creator.profile.icon }}"
alt="" class="circle">
<span class="title">Author</span>
<p><b>{{ challenge.creator.username }}</b></p>
</li>
<li class="collection-item">
<span class="title">Programming</span>
</li>
<li class="collection-item">
<span class="title">Soldering</span>
</li>
</ul>
{% if challenge.tags|length > 0 %}
<ul class="collection with-header">
<li class="collection-header">
<span class="title"><b>What we need</b></span>
<span class="title"><b>Tags</b></span>
</li>
{% for tag in challenge.tags.all %}
<li class="collection-item">
<span class="">CNC bench experience</span>
</li>
<li class="collection-item">
<span class="title">Screwdriver</span>
<span class="">{{ tag.name }}</span>
</li>
{% endfor %}
</ul>
{% endif %}
{% if challenge.tags|length > 0 %}
<ul class="collection with-header">
<li class="collection-header">
<span class="title"><b>Tags</b></span>
</li>
{% for tag in challenge.tags.all %}
<li class="collection-item">
<span class="">{{ tag.name }}</span>
</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
</div>