Skip to content

Commit

Permalink
added program manager role
Browse files Browse the repository at this point in the history
  • Loading branch information
sh1nkey committed Aug 4, 2024
1 parent e7dd828 commit d472f6b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
15 changes: 14 additions & 1 deletion partner_programs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ class PartnerProgramAdmin(admin.ModelAdmin):

filter_horizontal = ("users",)
date_hierarchy = "datetime_started"
change_form_template = "partner_programs/admin/programs_change_form.html"

def change_view(self, request, object_id, form_url="", extra_context=None):
if "Руководитель программы" in request.user.groups.all().values_list(
"name", flat=True
):
self.change_form_template = (
"partner_programs/admin/program_manager_change_form.html"
)
else:
self.change_form_template = "partner_programs/admin/programs_change_form.html"

return super().change_view(request, object_id, form_url, extra_context)

def get_urls(self):
default_urls = super(PartnerProgramAdmin, self).get_urls()
Expand All @@ -56,6 +67,8 @@ def get_urls(self):
return custom_urls + default_urls

def mailing(self, request, partner_program):
# if "Руководитель программы" in request.user.groups.all().values_list("name"):
# return None
profiles = PartnerProgramUserProfile.objects.filter(
partner_program=partner_program
)
Expand Down
34 changes: 34 additions & 0 deletions templates/partner_programs/admin/program_manager_change_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends "admin/change_form.html" %}
{% load i18n %}

{% block submit_buttons_bottom %}


{{ block.super }}
<div class="submit-row">
<input type="button" class="export-btn" value="Экспорт" onclick="export_profiles()"/>
</div>




<div class="submit-row">
<input type="button" class="export-btn" value="Выгрузка оценок" onclick="partner_programs_export_rates()"/>
</div>
<script>
function export_profiles() {

{% if object_id %}
window.open("{% url 'admin:export_profiles' object_id %}", '_blank').focus()
{% endif %}
}


function partner_programs_export_rates() {
{% if object_id %}
window.open("{% url 'admin:partner_programs_export_rates' object_id %}", '_blank').focus()
{% endif %}
}
</script>

{% endblock %}
3 changes: 3 additions & 0 deletions users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import tablib
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.models import Permission
from django.http import HttpResponse
from django.shortcuts import redirect
from django.urls import path
Expand All @@ -21,6 +22,8 @@

from core.admin import SkillToObjectInline

admin.site.register(Permission)


@admin.register(CustomUser)
class CustomUserAdmin(admin.ModelAdmin):
Expand Down

0 comments on commit d472f6b

Please sign in to comment.