Skip to content

Commit

Permalink
create form shows up
Browse files Browse the repository at this point in the history
  • Loading branch information
sheenarbw committed Nov 20, 2024
1 parent 2b7f1b3 commit cdbcc2b
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 3 deletions.
17 changes: 17 additions & 0 deletions proposals/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django import forms
from . import models


class ProposalForm(forms.ModelForm):
class Meta:
model = models.Proposal
fields = [
"title",
"proposal_type",
"track",
"description",
"private_notes",
"additional_speaker_emails",
"audience_level",
"accessibility_requests",
]
10 changes: 10 additions & 0 deletions proposals/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@
views.action_delete_my_proposal,
name="action_delete_my_proposal",
),
path(
"my_proposals/create",
views.create_proposal,
name="create_proposal",
),
# path(
# "my_proposals/create",
# views.action_create_proposal_submit,
# name="action_create_proposal_submit",
# ),
]
12 changes: 10 additions & 2 deletions proposals/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, Http404
from . import models
from django.http import Http404
from django.shortcuts import get_object_or_404
from . import models
from . import forms


@login_required
Expand All @@ -27,3 +28,10 @@ def action_delete_my_proposal(request, proposal_id):

context = {"proposals": proposals}
return render(request, "proposals/my_proposals.html#table_body", context)


@login_required
def create_proposal(request):
form = forms.ProposalForm()
context = {"form": form}
return render(request, "proposals/create_proposal.html", context)
11 changes: 11 additions & 0 deletions static/src/tailwind_final.css
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,12 @@ td {
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
}

.space-y-6 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(1.5rem * var(--tw-space-y-reverse));
}

.rounded {
border-radius: 0.25rem;
}
Expand Down Expand Up @@ -1173,6 +1179,11 @@ td {
line-height: 1rem;
}

.text-xl {
font-size: 1.25rem;
line-height: 1.75rem;
}

.font-bold {
font-weight: 700;
}
Expand Down
39 changes: 39 additions & 0 deletions templates/proposals/create_proposal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% extends "_base.html" %}
{% load tailwind_filters %}

{% load partials %}

{% partialdef form %}


{% if form.errors %}
<div id="proposal_form">

<p class="mb-8 text-xl"> <i class="fas fa-times-circle text-error-500 mr-3"> </i>Please correct the errors below.
</p>
{% endif %}


<form class="space-y-6" hx-post="{% url 'create_proposal' %}" hx-target="#proposal_form"
hx-disabled-elt="#proposal_form_button" hx-swap="outerHTML">
{{ form | crispy}}
<div>
<button type="submit" id="proposal_form_button" class="button w-full">
Create
</button>
</div>
</form>

</div>

{% endpartialdef %}



{% block content %}

<h1 class="pb-5">Create new proposal</h1>

{% partial form %}

{% endblock content %}
2 changes: 1 addition & 1 deletion templates/proposals/my_proposals.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h1>My Proposals</h1>
</table>
<div class="mb-8">

<a class="button ">Create new proposal</a>
<a class="button" href="{% url 'create_proposal' %}">Create new proposal</a>
</div>

{% endblock content %}

0 comments on commit cdbcc2b

Please sign in to comment.