Ejemplo n.º 1
0
def home(request):
    if request.user.is_authenticated():
        values = {}
        from usr import get_tzinfo
        tzinfo = get_tzinfo(request.user)
        if tzinfo:
            values['user_timezone'] = tzinfo.get('tzname')
            values['user_utcoffset'] = tzinfo.get('offset')
        return values
    else:
        return HttpResponseRedirect("/")
Ejemplo n.º 2
0
def main(request, name):
    """render user main page including self home page"""
    values = {}
    if name:
        values['user'] = user = get_object_or_404(User, name__iexact=name)
    else:
        user = request.user
    from usr import get_tzinfo
    tzinfo = get_tzinfo(user)
    if tzinfo:
        values['user_timezone'] = tzinfo.get('tzname')
        values['user_utcoffset'] = tzinfo.get('offset')
    return values
Ejemplo n.º 3
0
def main(request, tl_id):
    try:
        tl = Timelist.objects.get(Q(id=tl_id), Q(is_public=True)|Q(owner=request.user))
        values = {'timelist': tl, 'user': tl.owner}
        if tl.owner != request.user and request.user.is_authenticated():
            if request.user.tlistsubscribe_set.filter(timelist__id=tl_id):
                values['subscribing'] = True
            else:
                values['subscribing'] = False
        from usr import get_tzinfo
        tzinfo = get_tzinfo(tl.owner)
        if tzinfo:
            values['user_timezone'] = tzinfo.get('tzname')
            values['user_utcoffset'] = tzinfo.get('offset')
        return values
    except Timelist.DoesNotExist:
        from django.shortcuts import redirect
        return redirect(request.user)
Ejemplo n.º 4
0
def test(request):
    if request.user.is_authenticated():
        # get all timer belong to usr
        u = request.user
        ts = u.timer_set.all()
        tls = u.timelist_set.all()
        data = {'times':ts, 'tlists': tls}
        from usr import get_tzinfo
        tzinfo = get_tzinfo(request.user)
        if tzinfo:
            data['req_usr_timezone'] = tzinfo.get('tzname')
            data['req_usr_utcoffset'] = tzinfo.get('offset')
        if request.user.is_admin():
            from usr.models import User
            users = User.objects.all()
            data['users'] = users
        return data
    return {}