-
Notifications
You must be signed in to change notification settings - Fork 1
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
Superuser page for all opportunities. #450
Open
hemant10yadav
wants to merge
4
commits into
main
Choose a base branch
from
hy/superuser-opp-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
commcare_connect/templates/opportunity/all_opportunities_view.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{% extends "opportunity/base.html" %} | ||
{% load static %} | ||
{% load i18n %} | ||
{% block title %}{{ request.org }} - All Opportunities{% endblock %} | ||
|
||
{% block breadcrumbs_inner %} | ||
{{ block.super }} | ||
<li class="breadcrumb-item active" aria-current="page">All Opportunities</li> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container bg-white shadow"> | ||
<div class="mt-5 py-3"> | ||
<h1>All Opportunities</h1> | ||
</div> | ||
<div class="pb-4"> | ||
<form method="get" | ||
hx-get="{% url 'opportunity:all_opportunities' org_slug=request.org.slug %}" | ||
hx-target="#opportunity-table" | ||
hx-push-url="true" | ||
class="mb-3"> | ||
<div class="row g-3 align-items-center"> | ||
<div class="col-md-4"> | ||
<input type="text" | ||
name="search" | ||
value="{{ request.GET.search }}" | ||
class="form-control" | ||
placeholder="Search by name" | ||
aria-label="Search opportunities"> | ||
</div> | ||
<div class="col-md-3"> | ||
<select name="status" class="form-select"> | ||
<option value="">All</option> | ||
<option value="active" {% if request.GET.status == 'active' %}selected{% endif %}> | ||
Active | ||
</option> | ||
<option value="inactive" {% if request.GET.status == 'inactive' %}selected{% endif %}> | ||
Inactive | ||
</option> | ||
</select> | ||
</div> | ||
<div class="col-md-2"> | ||
<button type="submit" class="btn btn-primary">Search</button> | ||
</div> | ||
</div> | ||
</form> | ||
<div id="opportunity-table"> | ||
{% include 'opportunity/partial_opportunity_table.html' %} | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
commcare_connect/templates/opportunity/partial_opportunity_table.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{% load sort_link %} | ||
{% load django_tables2 %} | ||
{% load i18n %} | ||
<div d="opportunity-table"> | ||
<table class="table border table-responsive"> | ||
<thead class="table-light"> | ||
<tr> | ||
<th>{% sort_link 'name' 'Name' %}</th> | ||
<th>{% sort_link 'start_date' 'Start Date' %}</th> | ||
<th>{% sort_link 'end_date' 'End Date' %}</th> | ||
<th>Status</th> | ||
<th>Program</th> | ||
<th>Manage</th> | ||
</tr> | ||
</thead> | ||
<tbody x-ref="tbody"> | ||
{% for opportunity in page_obj %} | ||
<tr> | ||
<td>{{ opportunity.name }}</td> | ||
<td>{{ opportunity.start_date|default:"Not Set" }}</td> | ||
<td>{{ opportunity.end_date|default:"Not Set" }}</td> | ||
<td> | ||
{% if opportunity.is_setup_complete %} | ||
{% if opportunity.is_active %} | ||
<span class="badge bg-success rounded-pill">Active</span> | ||
{% else %} | ||
<span class="badge bg-secondary text-white rounded-pill">Inactive</span> | ||
{% endif %} | ||
{% else %} | ||
<span class="badge bg-warning text-white rounded-pill">Pending Setup</span> | ||
{% endif %} | ||
</td> | ||
<td>{% if opportunity.managed %} {{ opportunity.managedopportunity.program.name }} {% else %} - {% endif %}</td> | ||
<td width="300"> | ||
<div> | ||
<a class="btn btn-primary btn-sm" | ||
href="{% url 'opportunity:detail' org_slug=request.org.slug pk=opportunity.id %}"> | ||
<span class="bi bi-eye"></span><span class="d-none d-md-inline"> View</span> | ||
</a> | ||
{% if request.org_membership.is_viewer %} | ||
<button class="btn btn-warning btn-sm" disabled> | ||
<span class="bi bi-pen"></span><span class="d-none d-md-inline"> Edit</span> | ||
</button> | ||
{% if not opportunity.managed %} | ||
<button class="btn btn-primary btn-sm" disabled> | ||
<span class="bi bi-plus"></span><span class="d-none d-md-inline"> Add Budget</span> | ||
</button> | ||
{% endif %} | ||
{% else %} | ||
<a class="btn btn-warning btn-sm" | ||
href="{% url 'opportunity:edit' org_slug=request.org.slug pk=opportunity.id %}"><span | ||
class="bi bi-pen"></span><span class="d-none d-md-inline"> Edit</span></a> | ||
{% if not opportunity.managed %} | ||
<a class="btn btn-primary btn-sm" | ||
href="{% url 'opportunity:add_budget_existing_users' org_slug=request.org.slug pk=opportunity.id %}"><span | ||
class="bi bi-plus"></span><span class="d-none d-md-inline"> Add Budget</span> | ||
</a> | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
</td> | ||
|
||
</tr> | ||
{% empty %} | ||
<tr> | ||
<td colspan="3">{% translate "No opportunities yet." %}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<div> | ||
{% include 'pagination.html' %} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to make this change because the previous pagination template displayed all the page numbers, and as the number of pages increased, it started overflowing.