feat: added descriptions to categories

This commit is contained in:
Rushil Umaretiya 2021-09-20 06:25:34 -04:00
parent e446db893e
commit 244503d305
No known key found for this signature in database
GPG Key ID: 4E8FAF9C926AF959
4 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.7 on 2021-09-20 10:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0008_rename_available_challenge_unblocked'),
]
operations = [
migrations.RemoveField(
model_name='category',
name='slug',
),
migrations.AddField(
model_name='category',
name='description',
field=models.CharField(default='', max_length=200),
preserve_default=False,
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 3.2.7 on 2021-09-20 10:20
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0009_auto_20210920_1019'),
]
operations = [
migrations.RemoveField(
model_name='category',
name='category',
),
]

View File

@ -5,7 +5,7 @@ from ckeditor.fields import RichTextField
class Category(models.Model): class Category(models.Model):
id = models.AutoField(primary_key=True, null=False, blank=False) id = models.AutoField(primary_key=True, null=False, blank=False)
name = models.CharField(max_length=200, null=False, blank=False) name = models.CharField(max_length=200, null=False, blank=False)
category = models.CharField(max_length=200, null=False, blank=False) description = models.CharField(max_length=200, null=False, blank=False)
def __str__(self): def __str__(self):
return self.name return self.name

View File

@ -38,6 +38,9 @@
<h1 class="ml-3">{{ category.name }}</h1> <h1 class="ml-3">{{ category.name }}</h1>
<p style="cursor: pointer;" onclick="document.getElementById('c-{{ category.id }}').style.display = document.getElementById('c-{{ category.id }}').style.display === 'none' ? 'flex' : 'none'" class="ml-auto mr-3 btn btn-primary">toggle</p> <p style="cursor: pointer;" onclick="document.getElementById('c-{{ category.id }}').style.display = document.getElementById('c-{{ category.id }}').style.display === 'none' ? 'flex' : 'none'" class="ml-auto mr-3 btn btn-primary">toggle</p>
</div> </div>
<div class="row">
<p class="ml-2 font-italic">{{category.description}}</p>
</div>
<div id="c-{{ category.id }}" class='row'> <div id="c-{{ category.id }}" class='row'>
{% for challenge, status in challenges.items %} {% for challenge, status in challenges.items %}
{% if status.0.unblocked %} {% if status.0.unblocked %}