コード例 #1
0
ファイル: views.py プロジェクト: Pink-Waves/Fletter-Backend
 def get(self, request, addressee):
     user = ExtendedUser()
     try:
         user = ExtendedUser.objects.get(username=addressee)
     except:
         user = request.user
     self.queryset = Relationship.objects.filter(
         (Q(addressee=user.id) | Q(requester=user.id)),
         status='accepted').order_by(
             '-created_time')  #the - makes it sort from descending
     serializer = self.get_serializer(self.queryset, many=True)
     for i in serializer.data:  #add additional addtributes
         if (i['addressee'] == user.id):
             i['contact_username'] = ExtendedUser.objects.get(
                 id=i['requester']).username
             i['contact_birdColor'] = ExtendedUser.objects.get(
                 id=i['requester']).bird_color
             i['contact_address'] = ExtendedUser.objects.get(
                 id=i['requester']).number + " " + ExtendedUser.objects.get(
                     id=i['requester']
                 ).address + ", " + ExtendedUser.objects.get(
                     id=i['requester']).state
         else:
             i['contact_username'] = ExtendedUser.objects.get(
                 id=i['addressee']).username
             i['contact_birdColor'] = ExtendedUser.objects.get(
                 id=i['addressee']).bird_color
             i['contact_address'] = ExtendedUser.objects.get(
                 id=i['addressee']).number + " " + ExtendedUser.objects.get(
                     id=i['addressee']
                 ).address + ", " + ExtendedUser.objects.get(
                     id=i['addressee']).state
     return Response(serializer.data)
コード例 #2
0
ファイル: views.py プロジェクト: Pink-Waves/Fletter-Frontend
 def get(self, request, recipient):
     user = ExtendedUser()
     try:
         user = ExtendedUser.objects.get(username=recipient)
     except:
         user = request.user
     self.queryset = Message.objects.filter(recipient=user.id, status='deleted').order_by('-time') #the - makes it sort from descending
     serializer = self.get_serializer(self.queryset, many=True)
     for i in serializer.data: #add additional addtributes
         i['sender_username'] = ExtendedUser.objects.get(id=i['sender']).username
     return Response(serializer.data)
コード例 #3
0
    def get(self, request, token):
        user = ExtendedUser()
        try:
            user = ExtendedUser.objects.get(username=token)
        except:
            user = request.user
        print(user.bird_color)
        if (user.address == ''):
            addr = ''
        else:
            addr = user.number + ' ' + user.address + ', ' + user.state

        return Response({"color": user.bird_color, "address": addr})
コード例 #4
0
ファイル: views.py プロジェクト: Pink-Waves/Fletter-Backend
 def get(self, request, addressee):
     user = ExtendedUser()
     try:
         user = ExtendedUser.objects.get(username=addressee)
     except:
         user = request.user
     self.queryset = Relationship.objects.filter(
         addressee=user.id, status='pending').order_by(
             '-created_time')  #the - makes it sort from descending
     serializer = self.get_serializer(self.queryset, many=True)
     for i in serializer.data:  #add additional addtributes
         i['requester_username'] = ExtendedUser.objects.get(
             id=i['requester']).username
         i['requester_birdColor'] = ExtendedUser.objects.get(
             id=i['requester']).bird_color
     return Response(serializer.data)
コード例 #5
0
ファイル: views.py プロジェクト: Pink-Waves/Fletter-Frontend
 def get(self, request, recipient):
     user = ExtendedUser()
     try:
         user = ExtendedUser.objects.get(username=recipient)
     except:
         user = request.user
     #code for checking if there are any messages that should have been sent by now
     queryset = Message.objects.filter(Q(time__lte=datetime.now(), status='delayed') | Q(time__lte=datetime.now(), status='scheduled'))
     for message in queryset:
         message.status = 'sent'
         message.save()
     #query the messages
     self.queryset = Message.objects.filter(recipient=user.id, status='sent').order_by('-time') #the - makes it sort from descending
     serializer = self.get_serializer(self.queryset, many=True)
     for i in serializer.data: #add additional addtributes
         i['sender_username'] = ExtendedUser.objects.get(id=i['sender']).username
     return Response(serializer.data)
コード例 #6
0
ファイル: views.py プロジェクト: sagardhande2942/EcomWebsite
def register_view(request):
    next = request.GET.get('next')
    form = UserRegisterForm(request.POST or None)
    if form.is_valid():
        user = form.save(commit=False)
        password = form.cleaned_data.get('password')
        email = form.cleaned_data.get('email')
        print(email)
        user.set_password(password)
        new_user = authenticate(username=user.username, password=password)
        user.save()
        auth_token = str(uuid.uuid4())
        send_mail_after_registration(email, auth_token)
        ExtendedUser(usr=user, auth_token=auth_token).save()
        # login(request, new_user)
        # if next:
        #     return redirect(next)
        messages.info(request, 'Email is sent, please check your mail')
        return redirect('/auth/register')
    context = {
        'form': form,
    }
    return render(request, "Register.html", context)