feat: Add 'hidden' field to Activity model and update templates
Introduces a 'hidden' BooleanField to the Activity model to manage visibility of activities. Updates activity_edit and status_edit templates to support toggling this option. Improves clarity and maintainability by formatting HTML with better indentation and structuring. Excludes hidden activities from being displayed in status_edit. Enhances user interface for selective display and editing of activities.
This commit is contained in:
parent
8ffdeddf4a
commit
cfc8f6eefc
3 changed files with 196 additions and 87 deletions
|
@ -61,6 +61,7 @@ class Activity(models.Model):
|
||||||
icon = models.CharField(default="fas fa-check", max_length=64)
|
icon = models.CharField(default="fas fa-check", max_length=64)
|
||||||
color = ColorField(default="#000000")
|
color = ColorField(default="#000000")
|
||||||
category = models.ForeignKey(ActivityCategory, models.SET_NULL, null=True)
|
category = models.ForeignKey(ActivityCategory, models.SET_NULL, null=True)
|
||||||
|
hidden = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -1,30 +1,74 @@
|
||||||
{% extends "frontend/base.html" %}
|
{% extends "frontend/base.html" %}
|
||||||
{% block "content" %}
|
{% block "content" %}
|
||||||
|
<div class="card shadow mb-4">
|
||||||
<div class="card shadow mb-4">
|
<div class="card-header py-3">
|
||||||
<div class="card-header py-3">
|
<h6 class="m-0 font-weight-bold text-primary">Edit {{ object.name }}</h6>
|
||||||
<h6 class="m-0 font-weight-bold text-primary">Edit {{ object.name }}</h6>
|
</div>
|
||||||
</div>
|
<div class="card-body">
|
||||||
<div class="card-body">
|
<form action="" method="POST">
|
||||||
<form action="" method="POST">
|
{% csrf_token %}
|
||||||
{% csrf_token %}
|
<div class="table-responsive">
|
||||||
<div class="table-responsive">
|
<table>
|
||||||
<table>
|
<tr>
|
||||||
<tr><th><label for="id_name">Name:</label></th><td><input type="text" name="name" value="{{ object.name }}" maxlength="64" required id="id_name"></td></tr>
|
<th>
|
||||||
<tr><th><label for="id_icon">Icon:</label></th><td><input style="visibility: hidden;" class="icp icp-auto" type="text" name="icon" value="{{ object.icon }}" maxlength="64" required id="id_icon"></td></tr>
|
<label for="id_name">Name:</label>
|
||||||
<tr><th><label for="id_color">Color:</label></th><td><input type="text"
|
</th>
|
||||||
id="id_color"
|
<td>
|
||||||
class="form-control colorfield_field jscolor"
|
<input type="text"
|
||||||
name="color"
|
name="name"
|
||||||
value="{{ object.color }}"
|
value="{{ object.name }}"
|
||||||
placeholder="{{ object.color }}"
|
maxlength="64"
|
||||||
data-jscolor="{hash:true,width:225,height:150,required:true}"
|
required
|
||||||
required /></td></tr>
|
id="id_name">
|
||||||
</table>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
<button style="margin-top: 20px;" class="form-control btn-primary" type="submit">Save</button>
|
<tr>
|
||||||
</form>
|
<th>
|
||||||
</div>
|
<label for="id_icon">Icon:</label>
|
||||||
</div>
|
</th>
|
||||||
|
<td>
|
||||||
{% endblock %}
|
<input style="visibility: hidden"
|
||||||
|
class="icp icp-auto"
|
||||||
|
type="text"
|
||||||
|
name="icon"
|
||||||
|
value="{{ object.icon }}"
|
||||||
|
maxlength="64"
|
||||||
|
required
|
||||||
|
id="id_icon">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<label for="id_color">Color:</label>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<input type="text"
|
||||||
|
id="id_color"
|
||||||
|
class="form-control colorfield_field jscolor"
|
||||||
|
name="color"
|
||||||
|
value="{{ object.color }}"
|
||||||
|
placeholder="{{ object.color }}"
|
||||||
|
data-jscolor="{hash:true,width:225,height:150,required:true}"
|
||||||
|
required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<label for="id_hidden">Hidden:</label>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox"
|
||||||
|
name="hidden"
|
||||||
|
id="id_hidden"
|
||||||
|
{% if object.hidden %}checked{% endif %}>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<button style="margin-top: 20px"
|
||||||
|
class="form-control btn-primary"
|
||||||
|
type="submit">Save</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -1,62 +1,126 @@
|
||||||
{% extends "frontend/base.html" %}
|
{% extends "frontend/base.html" %}
|
||||||
{% load mood_categories %}
|
{% load mood_categories %}
|
||||||
{% block "content" %}
|
{% block "content" %}
|
||||||
|
{% if form.errors %}
|
||||||
{% if form.errors %}
|
{% for field in form %}
|
||||||
{% for field in form %}
|
{% for error in field.errors %}
|
||||||
{% for error in field.errors %}
|
<div class="alert alert-danger" role="alert">{{ field.name }}: {{ error }}</div>
|
||||||
<div class="alert alert-danger" role="alert">
|
{% endfor %}
|
||||||
{{ field.name }}: {{ error }}
|
{% endfor %}
|
||||||
</div>
|
{% endif %}
|
||||||
{% endfor %}
|
<div class="card shadow mb-4">
|
||||||
{% endfor %}
|
<div class="card-header py-3">
|
||||||
{% endif %}
|
<h6 class="m-0 font-weight-bold text-primary">Edit {{ object.name }}</h6>
|
||||||
<div class="card shadow mb-4">
|
</div>
|
||||||
<div class="card-header py-3">
|
<div class="card-body">
|
||||||
<h6 class="m-0 font-weight-bold text-primary">Edit {{ object.name }}</h6>
|
<form action="" method="POST" enctype="multipart/form-data">
|
||||||
</div>
|
{% csrf_token %}
|
||||||
<div class="card-body">
|
<div class="table-responsive">
|
||||||
<form action="" method="POST" enctype="multipart/form-data">
|
<table>
|
||||||
{% csrf_token %}
|
<tr>
|
||||||
<div class="table-responsive">
|
<th>
|
||||||
<table>
|
<label for="id_timestamp">Timestamp:</label>
|
||||||
<tr><th><label for="id_timestamp">Timestamp:</label></th><td><input type="text" name="timestamp" value="{% if object.timestamp %}{{ object.timestamp | date:"Y-m-d H:i" }}{% else %}{% now "Y-m-d H:i" %}{% endif %}" required id="id_timestamp"><input type="hidden" name="initial-timestamp" value="2020-12-26 19:24:14" id="initial-id_timestamp"></td></tr>
|
</th>
|
||||||
<tr><th><label for="id_title">Title:</label></th><td><input value="{{ object.title }}" type="text" name="title" maxlength="64" id="id_title"></td></tr>
|
<td>
|
||||||
<tr><th><label for="id_text">Text:</label></th><td><textarea name="text" cols="40" rows="10" id="id_text">{{ object.text }}</textarea></td></tr>
|
<input type="text"
|
||||||
|
name="timestamp"
|
||||||
<tr><th><label for="id_mood">Mood:</label></th><td><select name="mood" class="dtb" required id="id_mood">
|
value="{% if object.timestamp %}{{ object.timestamp | date:"Y-m-d H:i" }}{% else %}{% now "Y-m-d H:i" %}{% endif %}"
|
||||||
<option value="" {% if not object.mood %}selected{% endif %}>---------</option>
|
required
|
||||||
|
id="id_timestamp">
|
||||||
{% for mood in request.user.mood_set.all|dictsort:"value" %}
|
<input type="hidden"
|
||||||
<option data-color="{{ mood.color }}" data-icon="{{ mood.icon }}" value="{{ mood.id }}" {% if object.mood == mood %}selected{% endif %}>{{ mood }}</option>
|
name="initial-timestamp"
|
||||||
{% endfor %}
|
value="2020-12-26 19:24:14"
|
||||||
|
id="initial-id_timestamp">
|
||||||
</select></td></tr>
|
</td>
|
||||||
|
</tr>
|
||||||
<tr><th><label for="activities">Activities:</label></th><td>
|
<tr>
|
||||||
{% for activitycategory in request.user.activitycategory_set.all %}
|
<th>
|
||||||
|
<label for="id_title">Title:</label>
|
||||||
<p><b>{{ activitycategory.name }}</b></p>
|
</th>
|
||||||
|
<td>
|
||||||
{% for activity in activitycategory.activity_set.all|dictsort:"name" %}
|
<input value="{{ object.title }}"
|
||||||
<input type="checkbox" {% if activity in object.activity_set %}checked{% endif %} value="{{ activity.id }}" name="activities"> <i class="{{ activity.icon }}" style="color:{{ activity.color }};"></i> {{ activity }}<br>
|
type="text"
|
||||||
{% endfor %}
|
name="title"
|
||||||
{% endfor %}
|
maxlength="64"
|
||||||
|
id="id_title">
|
||||||
{% other_activities as activities %}
|
</td>
|
||||||
{% if activities %}<p><b>Uncategorized activities</b></p>{% endif%}
|
</tr>
|
||||||
|
<tr>
|
||||||
{% for activity in activities|dictsort:"name" %}
|
<th>
|
||||||
<input type="checkbox" {% if activity in object.activity_set %}checked{% endif %} value="{{ activity.id }}" name="activities"> <i class="{{ activity.icon }}" style="color:{{ activity.color }};"></i> {{ activity }}<br>
|
<label for="id_text">Text:</label>
|
||||||
{% endfor %}
|
</th>
|
||||||
</td></tr>
|
<td>
|
||||||
|
<textarea name="text" cols="40" rows="10" id="id_text">{{ object.text }}</textarea>
|
||||||
<tr><th><label for="id_uploads">Uploads:</label></th><td><input type="file" name="uploads" id="id_uploads" multiple="multiple"></td></tr>
|
</td>
|
||||||
</table>
|
</tr>
|
||||||
</div>
|
<tr>
|
||||||
<button style="margin-top: 20px;" class="form-control btn-primary" type="submit">Save</button>
|
<th>
|
||||||
</form>
|
<label for="id_mood">Mood:</label>
|
||||||
</div>
|
</th>
|
||||||
</div>
|
<td>
|
||||||
|
<select name="mood" class="dtb" required id="id_mood">
|
||||||
{% endblock %}
|
<option value="" {% if not object.mood %}selected{% endif %}>---------</option>
|
||||||
|
{% for mood in request.user.mood_set.all|dictsort:"value" %}
|
||||||
|
<option data-color="{{ mood.color }}"
|
||||||
|
data-icon="{{ mood.icon }}"
|
||||||
|
value="{{ mood.id }}"
|
||||||
|
{% if object.mood == mood %}selected{% endif %}>{{ mood }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<label for="activities">Activities:</label>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
{% for activitycategory in request.user.activitycategory_set.all %}
|
||||||
|
<p>
|
||||||
|
<b>{{ activitycategory.name }}</b>
|
||||||
|
</p>
|
||||||
|
{% for activity in activitycategory.activity_set.all|dictsort:"name" %}
|
||||||
|
{% if not activity.hidden %}
|
||||||
|
<input type="checkbox"
|
||||||
|
{% if activity in object.activity_set %}checked{% endif %}
|
||||||
|
value="{{ activity.id }}"
|
||||||
|
name="activities">
|
||||||
|
<i class="{{ activity.icon }}" style="color:{{ activity.color }};"></i> {{ activity }}
|
||||||
|
<br>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% other_activities as activities %}
|
||||||
|
{% if activities %}
|
||||||
|
<p>
|
||||||
|
<b>Uncategorized activities</b>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% for activity in activities|dictsort:"name" %}
|
||||||
|
{% if not activity.hidden %}
|
||||||
|
<input type="checkbox"
|
||||||
|
{% if activity in object.activity_set %}checked{% endif %}
|
||||||
|
value="{{ activity.id }}"
|
||||||
|
name="activities">
|
||||||
|
<i class="{{ activity.icon }}" style="color:{{ activity.color }};"></i> {{ activity }}
|
||||||
|
<br>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<label for="id_uploads">Uploads:</label>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<input type="file" name="uploads" id="id_uploads" multiple="multiple">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<button style="margin-top: 20px"
|
||||||
|
class="form-control btn-primary"
|
||||||
|
type="submit">Save</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue