Skip to content

Commit

Permalink
Add form styling and edit help messages for keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jwjacobson committed Dec 14, 2023
1 parent aa5ca48 commit 49d75ce
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
8 changes: 6 additions & 2 deletions tune/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Tune(models.Model):
("abac", "ABAC"),
("aba", "ABA"),
("abab", "ABAB"),
("abcd", "ABCD"),
("aab", "AAB"),
("blues", "blues"),
("irregular", "irregular"),
]
Expand Down Expand Up @@ -64,10 +66,12 @@ class Tune(models.Model):
key = models.CharField(
max_length=10,
blank=True,
help_text="One only, use single letter for major, add - for minor",
help_text="Letters A-G, one only, add - for minor",
)
other_keys = models.CharField(
max_length=20, blank=True, help_text="As many as you want, separated by a space"
max_length=20,
blank=True,
help_text="Letters A-G, as many as you want, separated by a space",
)
song_form = models.CharField(choices=FORMS, max_length=15, blank=True)
style = models.CharField(choices=STYLES, max_length=15, blank=True, default="standard")
Expand Down
30 changes: 9 additions & 21 deletions tune/templates/tune/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,27 @@ <h1>{% if post %}Edit{% else %}New{% endif %} Tune</h1>
{% csrf_token %}

This comment has been minimized.

Copy link
@ryaustin

ryaustin Dec 17, 2023

Collaborator

seems there is no post in context, might be more ideal to be if tune


{% for field in tune_form %}
<td>
<div>
{{ field.errors }}
<div class="mb-3">
<p>{{ field.label_tag }}</p>
{{ field }}
{{ field.errors }}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
</div>
</td>
{% endfor %}
<!-- {% for field in rep_form %}
<td>
<div>
{{ field.errors }}
{% for field in rep_form %}
<div class="mb-3">
<p>
<p>{{ field.label_tag }}</p>
{{ field }}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
</div>
</td>
{% endfor %} -->
<td>
<div>
<p>
{{ rep_form }}
{{ field.errors }}
</p>
</div>
</td>
{% endfor %}


<input type="submit" value="{% if post %}Edit{% else %}New{% endif %}" />
<a href="{% url 'tune:tune_list' %}">Go Back</a>
<input type="submit" class="btn btn-success" value="{% if post %}Save{% else %}Create{% endif %}" />

This comment has been minimized.

Copy link
@ryaustin

ryaustin Dec 17, 2023

Collaborator

same here, should probably be changed to {% if tune %}.
Should work with no further changes.

</form>

{% endblock %}
2 changes: 1 addition & 1 deletion tune/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def tune_edit(request, pk):
@login_required(login_url="/accounts/login/")
def tune_delete(request, pk):
tune = get_object_or_404(Tune, pk=pk)
rep_tune = RepertoireTune.objects.filter(tune=tune).get()
rep_tune = get_object_or_404(RepertoireTune, tune=tune, player=request.user)

if request.method == "POST":
deleted_id, deleted_title = tune.id, tune.title
Expand Down

0 comments on commit 49d75ce

Please sign in to comment.