Exemplo n.º 1
0
 def test_helper_no_profile(self):
     u = User()
     u.first_name = "John"
     u.last_name = "Smith"
     u.save()
     self.assertEquals(False, helpers.user_has_profile(u))
     p = Person()
     p.user = u
     p.save()
     self.assertEquals(True, helpers.user_has_profile(u))
Exemplo n.º 2
0
 def test_helper_no_profile(self):
     u = get_user_model()()
     u.first_name = "John"
     u.last_name = "Smith"
     u.save()
     self.assertEquals(False, helpers.user_has_profile(u))
     p = Person()
     p.user = u
     p.save()
     self.assertEquals(True, helpers.user_has_profile(u))
Exemplo n.º 3
0
 def process_request(self, request):
     if not(request.path == reverse('core:register') or
            request.path == reverse('login') or
            'admin' in request.path or
            'widget' in request.path):
         if request.user.is_authenticated():
             if not user_has_profile(request.user) or not request.user.is_active:
                 return HttpResponseRedirect(reverse('core:register'))
Exemplo n.º 4
0
 def process_request(self, request):
     if not (request.path == reverse('core:register')
             or request.path == reverse('login') or 'admin' in request.path
             or 'widget' in request.path):
         if request.user.is_authenticated():
             if not user_has_profile(
                     request.user) or not request.user.is_active:
                 return HttpResponseRedirect(reverse('core:register'))
Exemplo n.º 5
0
def main(req):
    if not user_has_profile(req.user):
        return HttpResponseRedirect(reverse('core:register'))
    p = create_params(req)
    p = get_front_page_data(req.user, p)
    # p['due_tasks'] = Requirement.due_for_user(req.user)
    # p['pneding_tasks'] = Requirement.pending_for_user(req.user)

    return render_to_response(TEMPLATE_PATH + 'index.html', p,
                              context_instance=RequestContext(req))
Exemplo n.º 6
0
def main(req):
    if not user_has_profile(req.user):
        return HttpResponseRedirect(reverse('core:register'))
    p = create_params(req)
    p = get_front_page_data(req.user, p)
    # p['due_tasks'] = Requirement.due_for_user(req.user)
    # p['pneding_tasks'] = Requirement.pending_for_user(req.user)

    return render_to_response(TEMPLATE_PATH + 'index.html',
                              p,
                              context_instance=RequestContext(req))
Exemplo n.º 7
0
def index(req, format='html'):
    """
    index of fedmash, display photos of new staff, teams and popular tags
    """
    if not user_has_profile(req.user):
        return HttpResponseRedirect(reverse('core:register'))
    p = _create_params(req)
    p['random_photos'] = Person.objects.filter(
        ~Q(photo_file="avatars/default.jpg")).filter(user__is_active=True). \
        order_by('-user__date_joined')[:20]
    p['divisions'] = OrgGroup.objects.filter(parent=None).order_by('title')
    p['offices'] = OrgGroup.objects.exclude(parent=None).order_by(
        'parent__title', 'title')
    p['tags'] = Tag.objects.filter(
        person__user__is_active=True,
        taggit_taggeditem_items__content_type__name='person'). \
        annotate(tag_count=Count('taggit_taggeditem_items')). \
        filter(tag_count__gte=20).order_by('-tag_count', 'name')
    return render_to_response(TEMPLATE_PATH + 'directory.html', p,
                              context_instance=RequestContext(req))
Exemplo n.º 8
0
def index(req, format='html'):
    """
    index of fedmash, display photos of new staff, teams and popular tags
    """
    if not user_has_profile(req.user):
        return HttpResponseRedirect(reverse('core:register'))
    p = _create_params(req)
    p['recent_photos'] = Person.objects.filter(
        ~Q(photo_file="avatars/default.jpg")).filter(user__is_active=True). \
        select_related('user', 'user__person'). \
        order_by('-updated_at')[:20]
    p['divisions'] = OrgGroup.objects.filter(parent=None).order_by('title')
    p['offices'] = OrgGroup.objects.exclude(parent=None).order_by(
        'parent__title', 'title')
    p['tags'] = Tag.objects.filter(
        person__user__is_active=True,
        taggit_taggeditem_items__content_type__name='person'). \
        annotate(tag_count=Count('taggit_taggeditem_items')). \
        filter(tag_count__gte=20).order_by('-tag_count', 'name')
    return render_to_response(TEMPLATE_PATH + 'directory.html',
                              p,
                              context_instance=RequestContext(req))