Exemplo n.º 1
0
def me_manual_view(request):
    """
    Save profile data manually input by auth user: birthdate, sex, etc.
    """
    if request.POST.get('dob', None):
        try:
            dob = dateutil.parser.parse(request.POST.get('dob', None)).date()
            request.user.profile.dob = dob
        except:
            # messages.error('')
            # Older browsers may submit a completely malformated dob. Ignore it
            # and carry on, no good to bother the user with this during the
            # signup flow.
            dob = datetime(year=1990, month=1, day=1).date()

        if get_age(dob) < 18:
            messages.warning(request, 'sorry, you need to be 18 or older '
                                      'to sign up on this site.')
            return redirect(reverse('me_page') + '#id_profile')

    if request.POST.get('sex', None):
        request.user.profile.sex = force_int(request.POST.get('sex'))
    if request.POST.get('about', None):
        request.user.profile.about = request.POST.get('about')
    if request.POST.getlist('lookingfor', None):
        request.user.profile.lookingfor = request.POST.getlist('lookingfor')

    if request.POST.get('pref_distance_unit', None):
        request.user.profile.pref_distance_unit = \
            request.POST.get('pref_distance_unit')

    if request.POST.get('herefor', None):
        request.user.profile.herefor = request.POST.get('herefor')

    if request.POST.get('tagline', None):  # unused
        request.user.profile.tagline = request.POST.get('tagline')
    if request.POST.get('relstatus', None):  # unused
        request.user.profile.relstatus = request.POST.get('relstatus')
    if request.POST.get('education', None):  # unused
        request.user.profile.education = request.POST.get('education')
    if request.POST.get('height', None):  # unused
        request.user.profile.height = request.POST.get('height')
    if request.POST.get('weight', None):  # unused
        request.user.profile.weight = request.POST.get('weight')
    if request.POST.get('fitness', None):  # unused
        request.user.profile.fitness = request.POST.get('fitness')

    request.user.profile.save()
    # messages.success(request, 'Profile data updated.')

    if request.is_ajax():
        return HttpResponse()  # HTTP 200

    _next = request.POST.get('next', '#id_profile')
    if _next.startswith('#'):
        _next = reverse('me_page') + _next
    return redirect(_next)
Exemplo n.º 2
0
def me_manual_view(request):
    """
    Save profile data manually input by auth user: birthdate, sex, etc.
    """
    if request.POST.get("dob", None):
        try:
            dob = dateutil.parser.parse(request.POST.get("dob", None)).date()
            request.user.profile.dob = dob
        except:
            # messages.error('')
            # Older browsers may submit a completely malformated dob. Ignore it
            # and carry on, no good to bother the user with this during the
            # signup flow.
            dob = datetime(year=1990, month=1, day=1).date()

        if get_age(dob) < 18:
            messages.warning(
                request, "sorry, you need to be 18 or older " "to sign up on this site."
            )
            return redirect(reverse("me_page") + "#id_profile")

    if request.POST.get("sex", None):
        request.user.profile.sex = force_int(request.POST.get("sex"))
    if request.POST.get("about", None):
        request.user.profile.about = request.POST.get("about")
    if request.POST.getlist("lookingfor", None):
        request.user.profile.lookingfor = request.POST.getlist("lookingfor")

    if request.POST.get("pref_distance_unit", None):
        request.user.profile.pref_distance_unit = request.POST.get("pref_distance_unit")

    if request.POST.get("herefor", None):
        request.user.profile.herefor = request.POST.get("herefor")

    if request.POST.get("tagline", None):  # unused
        request.user.profile.tagline = request.POST.get("tagline")
    if request.POST.get("relstatus", None):  # unused
        request.user.profile.relstatus = request.POST.get("relstatus")
    if request.POST.get("education", None):  # unused
        request.user.profile.education = request.POST.get("education")
    if request.POST.get("height", None):  # unused
        request.user.profile.height = request.POST.get("height")
    if request.POST.get("weight", None):  # unused
        request.user.profile.weight = request.POST.get("weight")
    if request.POST.get("fitness", None):  # unused
        request.user.profile.fitness = request.POST.get("fitness")

    request.user.profile.save()
    # messages.success(request, 'Profile data updated.')

    if request.is_ajax():
        return HttpResponse()  # HTTP 200

    _next = request.POST.get("next", "#id_profile")
    if _next.startswith("#"):
        _next = reverse("me_page") + _next
    return redirect(_next)
Exemplo n.º 3
0
def me_manual_view(request):
    """
    Save profile data manually input by auth user: birthdate, sex, etc.
    """
    if request.POST.get('dob', None):
        try:
            dob = dateutil.parser.parse(request.POST.get('dob', None)).date()
            request.user.profile.dob = dob
        except:
            dob = 0
        if get_age(dob) < 18:
            messages.warning(request, 'sorry, you need to be 18 or older '
                                      'to sign up on this site.')
            return redirect(reverse('me_page') + '#id_profile')

    if request.POST.get('sex', None):
        request.user.profile.sex = force_int(request.POST.get('sex'))
    if request.POST.get('about', None):
        request.user.profile.about = request.POST.get('about')
    if request.POST.getlist('lookingfor', None):
        request.user.profile.lookingfor = request.POST.getlist('lookingfor')

    if request.POST.get('pref_distance_unit', None):
        request.user.profile.pref_distance_unit = \
            request.POST.get('pref_distance_unit')

    if request.POST.get('tagline', None):  # unused
        request.user.profile.tagline = request.POST.get('tagline')
    if request.POST.get('relstatus', None):  # unused
        request.user.profile.relstatus = request.POST.get('relstatus')
    if request.POST.get('education', None):  # unused
        request.user.profile.education = request.POST.get('education')
    if request.POST.get('height', None):  # unused
        request.user.profile.height = request.POST.get('height')
    if request.POST.get('weight', None):  # unused
        request.user.profile.weight = request.POST.get('weight')
    if request.POST.get('fitness', None):  # unused
        request.user.profile.fitness = request.POST.get('fitness')

    request.user.profile.save()
    messages.success(request, 'Profile data updated.')
    _next = request.POST.get('next', '#id_profile')
    if _next.startswith('#'):
        _next = reverse('me_page') + _next

    return redirect(_next)
Exemplo n.º 4
0
def me_manual_view(request):
    """
    Save profile data manually input by auth user: birthdate, sex, etc.
    """
    if request.POST.get('dob', None):
        try:
            dob = dateutil.parser.parse(request.POST.get('dob', None)).date()
            request.user.profile.dob = dob
        except:
            dob = 0
        if get_age(dob) < 18:
            messages.warning(request, 'sorry, you need to be 18 or older '
                                      'to sign up on this site.')
            return redirect(reverse('me_page') + '#id_profile')

    if request.POST.get('sex', None):
        request.user.profile.sex = force_int(request.POST.get('sex'))
    if request.POST.get('about', None):
        request.user.profile.about = request.POST.get('about')
    if request.POST.getlist('lookingfor', None):
        request.user.profile.lookingfor = request.POST.getlist('lookingfor')

    if request.POST.get('tagline', None):  # unused
        request.user.profile.tagline = request.POST.get('tagline')
    if request.POST.get('relstatus', None):  # unused
        request.user.profile.relstatus = request.POST.get('relstatus')
    if request.POST.get('education', None):  # unused
        request.user.profile.education = request.POST.get('education')
    if request.POST.get('height', None):  # unused
        request.user.profile.height = request.POST.get('height')
    if request.POST.get('weight', None):  # unused
        request.user.profile.weight = request.POST.get('weight')
    if request.POST.get('fitness', None):  # unused
        request.user.profile.fitness = request.POST.get('fitness')

    request.user.profile.save()
    messages.success(request, 'Profile data updated.')
    return redirect(reverse('me_page') + '#id_profile')
Exemplo n.º 5
0
Arquivo: models.py Projeto: C14L/dtr5
 def age(self):
     return get_age(self.dob)
Exemplo n.º 6
0
Arquivo: models.py Projeto: C14L/dtr5
 def get_age(self):
     try:
         return get_age(self.dob)
     except:
         return ""
Exemplo n.º 7
0
 def get_age(self):
     try:
         return get_age(self.dob)
     except:
         return ''