Ejemplo n.º 1
0
def get_school(request):
    user = request.user
    if not user.is_anonymous():
        if 'school' in request.session.keys():
            return request.session['school']
        school_id = SchoolID.get_current_school_id(user)
        if school_id:
            return school_id.school
    return None
Ejemplo n.º 2
0
 def __init__(self, user, *args, **kwargs):
     super(SendEmailForm, self).__init__(*args, **kwargs)
     message = u'\n\n\n--\n%s' % user.get_full_name()
     if user.is_superuser:
         from django.contrib.auth.models import User
         self.fields['recipients'] = CoachMultipleChoiceField(queryset=User.objects.filter(is_active=True).exclude(id=user.id).order_by('last_name'),
                                                              help_text=u'Hold down "Control", or "Command" on a Mac, to select more than one.')
         message += u'\nGLML Administrator'
     school_id = SchoolID.get_current_school_id(user)
     if school_id:
         message += u'\nGLML Coach for %s' % (school_id.school.name)
     self.fields['subject'] = forms.CharField(initial=u'GLML')
     self.fields['message'] = forms.CharField(initial=message, widget=forms.Textarea)
Ejemplo n.º 3
0
 def label_from_instance(self, coach):
     label = u'%s, %s' % (coach.last_name, coach.first_name)
     school_id = SchoolID.get_current_school_id(coach)
     if school_id:
         label += u' (%s)' % school_id.school
     return label