Exemple #1
0
class StudentAdmin(VersionAdmin, ReadPermissionModelAdmin, CustomFieldAdmin):
    def changelist_view(self, request, extra_context=None):
        """override to hide inactive students by default"""
        try:
            test = request.META['HTTP_REFERER'].split(
                request.META['PATH_INFO'])
            if test and test[-1] and not test[-1].startswith(
                    '?') and not request.GET.has_key(
                        'inactive__exact') and not request.GET.has_key(
                            'id__in'):
                return HttpResponseRedirect(
                    "/admin/lgmssis/student/?inactive__exact=0")
                #admin/lgmssis/student/change_list.html
        except:
            pass  # In case there is no referer
        return super(StudentAdmin,
                     self).changelist_view(request,
                                           extra_context=extra_context)

    def lookup_allowed(self, lookup, *args, **kwargs):
        if lookup in ('id', 'id__in', 'year__id__exact'):
            return True
        return super(StudentAdmin,
                     self).lookup_allowed(lookup, *args, **kwargs)

    def render_change_form(self, request, context, *args, **kwargs):
        try:
            if context['original'].pic:
                txt = '<img src="' + str(
                    context['original'].pic.url_70x65) + '"/>'
                context['adminform'].form.fields['pic'].help_text += txt
        except:
            print("Error in StudentAdmin render_change_form", file=sys.stderr)

        if 'lgmsbenchmarkgrade' in settings.INSTALLED_APPS:
            context['adminform'].form.fields[
                'family_access_users'].queryset = User.objects.filter(
                    groups__name='family')

        return super(StudentAdmin,
                     self).render_change_form(request, context, *args,
                                              **kwargs)

    def change_view(self, request, object_id, extra_context=None):
        courses = Course.objects.filter(
            courseenrollment__user__id=object_id,
            marking_period__school_year__active_year=True).distinct()
        for course in courses:
            course.enroll = course.courseenrollment_set.get(
                user__id=object_id).id
        other_courses = Course.objects.filter(
            courseenrollment__user__id=object_id,
            marking_period__school_year__active_year=False).distinct()
        for course in other_courses:
            course.enroll = course.courseenrollment_set.get(
                user__id=object_id).id
        my_context = {
            'courses': courses,
            'other_courses': other_courses,
        }
        return super(StudentAdmin, self).change_view(request,
                                                     object_id,
                                                     extra_context=my_context)

    def save_model(self, request, obj, form, change):
        super(StudentAdmin, self).save_model(request, obj, form, change)
        form.save_m2m()
        if 'lgmsbenchmarkgrade' in settings.INSTALLED_APPS:
            group = Group.objects.get_or_create(name='family')[0]
            for user in obj.family_access_users.all():
                user.groups.add(group)
                user.save()

    def get_form(self, request, obj=None, **kwargs):
        exclude = []
        if not request.user.has_perm('sis.view_ssn_student'):
            exclude.append('ssn')
        if not 'lgmsbenchmarkgrade' in settings.INSTALLED_APPS:
            exclude.append('family_access_users')
        if len(exclude):
            kwargs['exclude'] = exclude
        form = super(StudentAdmin, self).get_form(request, obj, **kwargs)
        autoselect_fields_check_can_add(StudentForm, self.model, request.user)
        return form

    fieldsets = [
        (None, {
            'fields': [
                ('last_name', 'first_name'),
                ('year'),
                ('date_dismissed', 'reason_left'),
                'username',
                'grad_date',
                'pic',
                ('sex', 'bday'),
                'class_of_year',
                ('unique_id', 'lrn_no'),
                'parent_email',
                'notes',
                'siblings',
            ]
        }),
    ]
    if 'lgmsbenchmarkgrade' in settings.INSTALLED_APPS:
        fieldsets[0][1]['fields'].append('family_access_users')
    change_list_template = "admin/lgmssis/student/change_list.html"
    form = StudentForm
    search_fields = [
        'first_name', 'last_name', 'username', 'lrn_no', 'streetname', 'state',
        'zip', 'id'
    ]
    inlines = [
        StudentHealthRecordInline, TranscriptNoteInline, StudentAwardInline
    ]
    actions = [promote_to_worker, mark_inactive]
    #list_filter = ['inactive','year']
    #list_display = ['__str__','year']
    if 'lgmsbenchmarkgrade' in settings.INSTALLED_APPS:
        #filter_horizontal = ('family_access_users',)

        try:
            from admin_import.options import add_import
        except ImportError:
            pass
        else:
            add_import(StudentAdmin, add_button=True)
Exemple #2
0
        StudentNumberInline, StudentCohortInline, StudentFileInline,
        StudentHealthRecordInline, TranscriptNoteInline, StudentAwardInline
    ]
    actions = [promote_to_worker, mark_inactive]
    list_filter = ['inactive', 'year', 'class_of_year']
    list_display = ['__unicode__', 'year']
    if 'ecwsp.benchmark_grade' in settings.INSTALLED_APPS:
        filter_horizontal = ('family_access_users', )


try:
    from admin_import.options import add_import
except ImportError:
    pass
else:
    add_import(StudentAdmin)
admin.site.register(Student, StudentAdmin)
admin.site.register(ClassYear)


### Second student admin just for courses
class StudentCourse(Student):
    class Meta:
        proxy = True


class StudentCourseAdmin(admin.ModelAdmin):
    inlines = [StudentCourseInline]
    search_fields = [
        'fname', 'lname', 'username', 'unique_id', 'street', 'state', 'zip',
        'id'
Exemple #3
0
    form = StudentForm
    readonly_fields = ['year']
    search_fields = ['first_name', 'last_name', 'username', 'unique_id', 'street', 'state', 'zip', 'id', 'studentnumber__number']
    inlines = [StudentNumberInline, StudentCohortInline, StudentFileInline, StudentHealthRecordInline, TranscriptNoteInline, StudentAwardInline]
    actions = [mark_inactive]
    list_filter = ['is_active', 'year', 'class_of_year']
    list_display = ['first_name','last_name','year','is_active','primary_cohort', 'phone', 'gpa']
    if 'ecwsp.benchmark_grade' in settings.INSTALLED_APPS:
        filter_horizontal = ('family_access_users',)
        
try:
    from admin_import.options import add_import
except ImportError:
    pass
else:
    add_import(StudentAdmin)

admin.site.register(Student, StudentAdmin)
admin.site.register(ClassYear)

### Second student admin just for courses
class StudentCourse(Student):
    class Meta:
        proxy = True
class StudentCourseAdmin(admin.ModelAdmin):
    inlines = [StudentCourseInline]
    search_fields = ['first_name', 'last_name', 'username', 'unique_id', 'street', 'state', 'zip', 'id']
    fields = ['first_name', 'last_name']
    list_filter = ['is_active','year']
    readonly_fields = fields
admin.site.register(StudentCourse, StudentCourseAdmin)
Exemple #4
0
    change_list_template = "admin/sis/student/change_list.html"
    form = StudentForm
    search_fields = ['fname', 'lname', 'username', 'unique_id', 'street', 'state', 'zip', 'id']
    inlines = [StudentNumberInline, StudentCohortInline, StudentFileInline, StudentHealthRecordInline, TranscriptNoteInline, StudentAwardInline]
    actions = [promote_to_worker, mark_inactive]
    list_filter = ['inactive','year']
    list_display = ['__unicode__','year']
    if 'ecwsp.benchmark_grade' in settings.INSTALLED_APPS:
        filter_horizontal = ('family_access_users',)
        
try:
    from admin_import.options import add_import
except ImportError:
    pass
else:
    add_import(StudentAdmin, add_button=True)
admin.site.register(Student, StudentAdmin)
admin.site.register(ClassYear)

### Second student admin just for courses
class StudentCourse(Student):
    class Meta:
        proxy = True
class StudentCourseAdmin(admin.ModelAdmin):
    inlines = [StudentCourseInline]
    search_fields = ['fname', 'lname', 'username', 'unique_id', 'street', 'state', 'zip', 'id']
    fields = ['fname', 'lname']
    list_filter = ['inactive','year']
    readonly_fields = fields
admin.site.register(StudentCourse, StudentCourseAdmin)
Exemple #5
0
from django.contrib import admin

from pennyblack.module.subscriber.models import NewsletterSubscriber,\
    NewsletterSubscriberAdmin, SubscriberGroup, SubscriberGroupAdmin

admin.site.register(NewsletterSubscriber, NewsletterSubscriberAdmin)
admin.site.register(SubscriberGroup, SubscriberGroupAdmin)

try:
    from admin_import.options import add_import
except ImportError, e:
    if not str(e) == 'No module named admin_import.options':
        raise
else:
    from django.conf import settings as django_settings
    if 'admin_import' in django_settings.INSTALLED_APPS:
        add_import(NewsletterSubscriberAdmin, add_button=True)
Exemple #6
0
from django.contrib import admin
from django.contrib import admin

from .models import *

admin.site.register(Employee)
admin.site.register(EmployeeLeaveMaster)
admin.site.register(EmployeeLeaveTransaction)
admin.site.register(EmployeeAddress)
admin.site.register(EmployeeProject)
admin.site.register(PhoneNumber)
admin.site.register(Project)
admin.site.register(EmployeeLeaveLog)
admin.site.register(Leave)
admin.site.register(IsEmployeeHR)
admin.site.register(Logincredentials)

try:
    from admin_import.options import add_import
except ImportError:
    pass
else:
    add_import(InviteeAdmin)


from django.contrib import admin
from django import forms
import os.path, pkgutil
from inference2 import Proofs
from inference2.models import Define3, Archives
from django.contrib.auth.models import User
from django.forms import ModelForm

from django.contrib import admin

try:
    from admin_import.options import add_import
except ImportError:
    pass
else:
    add_import(admin.ModelAdmin, add_button=True)
from inference2.models import Define3,Input
from django.contrib import admin
from .actions import export_as_csv_action
from .actions import change_text_to_symbol_action
from .actions import change_symbol_to_text_action
from .actions import export_as_json_action
from .actions import export_as_xml_action
from .actions import export_as_yaml_action

from admincsv import ImportCSVModelAdmin
admin.site.add_action(export_as_csv_action)
admin.site.add_action(change_text_to_symbol_action)
admin.site.add_action(change_symbol_to_text_action)
class AuthorAdmin(admin.ModelAdmin):
    list_display = ('id','extra','type','word', 'rel','')