Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove PaymentProofForm and related views and templates #81

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions corpus/impulse/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ class AnnouncementForm(CorpusModelForm):
class Meta:
model = Announcement
fields = ["content", "url_link", "url_link_text", "announcement_type", "announcement_mailing"]

class PaymentProofForm(CorpusModelForm):
class Meta:
model = Team
fields = ["payment_proof"]

class InviteForm(CorpusModelForm):
class Meta:
Expand Down
2 changes: 1 addition & 1 deletion corpus/impulse/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ class Migration(migrations.Migration):
name='user',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]
]
17 changes: 17 additions & 0 deletions corpus/impulse/migrations/0002_remove_team_payment_proof.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.7 on 2024-01-03 06:06

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('impulse', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='team',
name='payment_proof',
),
]
2 changes: 0 additions & 2 deletions corpus/impulse/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ class Team(models.Model):
ImpulseUser, on_delete=models.CASCADE, related_name="leader"
)


payment_status = models.CharField(
max_length=1, choices=PAYMENT_STATUS, blank=False, null=False, default="U"
)
payment_proof = models.ImageField(upload_to="img/impulse/payment_proofs", blank=True, null=True)

def __str__(self):
return self.team_name
Expand Down
2 changes: 0 additions & 2 deletions corpus/impulse/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
path(
"delete_invite/<int:pk>", views.delete_invite, name="impulse_delete_invite"
),
path("upload_payment_proof", views.upload_payment_proof, name="impulse_upload_payment_proof"),
path("delete_payment_proof", views.delete_payment_proof, name="impulse_delete_payment_proof"),
path("admin", views.admin, name="impulse_admin"),
path("admin/teams", views.team_management, name="impulse_admin_teams"),
path("admin/team/<int:pk>", views.team_page, name="impulse_admin_team_page"),
Expand Down
34 changes: 1 addition & 33 deletions corpus/impulse/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from impulse.forms import ImpulseForm
from impulse.forms import TeamCreationForm
from impulse.forms import AnnouncementForm
from impulse.forms import PaymentProofForm
from impulse.forms import InviteForm
from corpus.decorators import ensure_group_membership
from corpus.decorators import module_enabled
Expand Down Expand Up @@ -127,9 +126,7 @@ def index(request):
registration_active = (reg_start_datetime <= datetime.now()) and (
datetime.now() <= reg_end_datetime
)

args["payment_proof_form"] = PaymentProofForm()


args["registration_active"] = registration_active

try :
Expand Down Expand Up @@ -326,35 +323,6 @@ def delete_invite(request, pk):
return redirect("impulse_index")


@login_required
@module_enabled(module_name="impulse")
def upload_payment_proof(request):
if request.method == "POST":
impulse_user = ImpulseUser.objects.get(user=request.user)
team = Team.objects.get(team_leader=impulse_user)

if team.payment_proof is not None:
team.payment_proof.delete()
team.payment_proof = request.FILES["payment_proof"]
if team.payment_proof is None:
messages.error(request, "Please upload a file!")
return redirect("impulse_index")
team.save()
messages.success(request, "Successfully uploaded payment proof!")
return redirect("impulse_index")
else:
return redirect("impulse_index")

@login_required
@module_enabled(module_name="impulse")
def delete_payment_proof(request):
impulse_user = ImpulseUser.objects.get(user=request.user)
team = Team.objects.get(team_leader=impulse_user)
team.payment_proof.delete()
team.save()
messages.success(request, "Successfully deleted payment proof!")
return redirect("impulse_index")

@login_required
@ensure_group_membership(group_names=["impulse_admin"])
def admin(request):
Expand Down
37 changes: 8 additions & 29 deletions corpus/templates/impulse/admin/team_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,29 @@ <h3>Members</h3>
<tr>
<th></th>
<th>Name</th>
<th>Email</th>
<th>From NITK?</th>
<th>College Name</th>
<th>IEEE Member?</th>
<th>IEEE Membership Number</th>
</tr>
</thead>
<tbody>
{% for member in members %}
<tr>
<td>1</td>
<td>{{ team.team_leader.user }}</td>
<td>{{ team.team_leader.user.email }}</td>
<td>{{ team.team_leader.from_nitk|yesno:"Yes,No" }}</td>
<td>{{ team.team_leader.college_name }}</td>
<td>{{ team.team_leader.ieee_member|yesno:"Yes,No" }}</td>
<td>{{ team.team_leader.ieee_membership_no }}</td>
</tr>
<tr>
<td>2</td>
<td>{{ team.member_name }}</td>
<td>{{ team.member_email }}</td>
<td>{{ team.member_from_nitk|yesno:"Yes,No" }}</td>
<td>{{ team.member_college_name }}</td>
<td>{{ team.member_ieee_member|yesno:"Yes,No" }}</td>
<td>{{ team.member_ieee_membership_no }}</td>
<td>{{ forloop.counter }}</td>
<td>{{ member.user }}</td>
<td>{{ member.from_nitk|yesno:"Yes,No" }}</td>
<td>{{ member.college_name }}</td>
<td>{{ member.ieee_member|yesno:"Yes,No" }}</td>
<td>{{ member.ieee_membership_no }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<p><strong>Payment status:</strong> {{ team.get_payment_status_display }}</p>

{% if team.payment_proof %}
<div class="my-5">
<p class="text-green-500">Payment proof uploaded</p>
<img src="{% static team.payment_proof.url %}" alt="Payment proof" class="my-5 max-w-xs">
<p><a href="{% static team.payment_proof.url %}" download>Download</a></p>
</div>
{% else %}
{% if team.payment_status == "U" %}
<p class="text-red-500">Payment proof not uploaded</p>
{% endif %}
{% endif %}

{% if team.payment_status == "U" %}
<a href="{% url 'impulse_admin_mark_payment_complete' pk=team.pk %}"
class="btn btn-success text-black font-bold no-underline">Mark Payment as Complete</a>
Expand Down
54 changes: 1 addition & 53 deletions corpus/templates/impulse/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,60 +136,8 @@ <h4> Join the Discord Server </h4>
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<span>
Please pay the fee of <strong>Rs. 150</strong> here :
<button class="btn btn-primary btn-sm dark:bg-gray-200 dark:hover:bg-gray-400" onclick="upiQR_modal.showModal()">CLICK HERE</button>
If you have already paid the fee, it might take some time for it to be updated
here. Please only contact us if it has not been updated for more than a week.
Please pay the fee of <strong>Rs. 150</strong> <a href="https://in.explara.com/e/impulse-2024">here </a>. If you have already paid the fee, it might take some time for it to be updated here. Please only contact us if it has not been updated for more than a week.
</span>
<dialog id="upiQR_modal" class="modal">
<div class="modal-box">
<form method="dialog">
<button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2 dark:text-white">✕</button>
</form>

<div class="my-2">
{% comment %} https://in.explara.com/e/impulse-2024?v=m {% endcomment %}
<a href="https://in.explara.com/e/impulse-2024?v=m" target="_blank">
Impulse 2024 Payment
</a>
<p class="text-center dark:text-white">Register and Pay the fee for this Event <span class="text-red-200">(Rs. 150 PER TEAM)</span> here.</p>
<form method="post" action="{% url 'impulse_upload_payment_proof' %}" class="py-3 dark:text-white" enctype="multipart/form-data">
{% csrf_token %}
<div class="my-2 dark:text-primary">
<label for="{{ payment_proof_form.payment_proof.id_for_label }}">Ticket / Receipt Screenshot<span class="text-red-500">*</span></label>
{{ payment_proof_form.payment_proof }}
{% if payment_proof_form.payment_proof.errors %}
<div class="my-1">
<div role="alert" class="alert alert-error">
{{ payment_proof_form.payment_proof.errors }}
</div>
</div>
{% endif %}
<p class="text-center"><span class="text-red-500">*</span> Please upload a screenshot of the ticket / receipt you get after paying the fee.</p>
</div>
<div class="my-2">
<button class="btn btn-primary btn-block text-primary hover:text-white" type="submit">Upload Registration Proof</button>
</div>
</form>
{% if team.payment_proof %}
<div class="my-2 dark:text-white">
<p class="text-center">Your Registration proof has been uploaded. It will be verified soon.</p>
{% comment %} uploaded image {% endcomment %}
<div class="my-2">
<p class="text-center">Uploaded Image</p>
<img src="{% static team.payment_proof.url %}" alt="UPI QR Code" class="w-64 mx-auto">
{% comment %} delete button {% endcomment %}
<form method="post" action="{% url 'impulse_delete_payment_proof' %}" class="py-5">
{% csrf_token %}
<div class="my-2">
<button class="btn btn-primary btn-block text-primary hover:text-white" type="submit">Delete Registration Proof</button>
</div>
</form>
</div>
</div>
{% endif %}
</div>
</dialog>
</div>
{% endif %}
<div class="rounded-lg p-3 flex flex-col gap-2">
Expand Down