예제 #1
0
def view_people(request):
    age = description = location = candidate = userid = photo = ''
    user = request.user
    chats = UserChat.chats_info(user)
    my_data = UserData.objects.get(user=request.user)
    personality_error = False
    if not my_data.personality or not have_i_question(my_data):  # jesli nie ma osobowosci lub conajmniej 1 pytania
        display = False
    else:
        candidate = select_comrade_for_me(request.user)
        userid = candidate.id
        if request.user == candidate:
            display = False
        else:
            display = True
            candidate_info = UserData.objects.filter(user=candidate)

            for u in candidate_info:
                description = u.description
                if u.photo:
                    photo = u.photo
                else:
                    photo = "/images/user_profile_pictures/default.jpg/"
                age = calculate_age(u.birth)
                location = float("{0:.2f}".format(distance_between(candidate, request.user)))
    return render(request, 'html_pages/view_people.html',
                  {"personerror": personality_error, 'chats': chats, 'username': user.username, "desc": description,
                   "age": age, "loc": location,
                   "nick": candidate, "name": userid, "photo": photo,
                   "display": display, 'media_url': settings.STATIC_URL})
예제 #2
0
    def update(self):

        if functions.distance_between(self.rect,data.player.rect)> self.SENSES:
            if self.timetochangedirection <= 0:
                self.direction = direction.random()
            
            self.timeleft -= 1
            
        else:
            self.move(direction.to_vector(ai.pathfinding(self.rect, data.player.rect),self.SPEED))
예제 #3
0
def view_answers(request):
    # tu elementu ktore zwroce
    questions = []
    descriptions = []
    photos = []
    users_ids = []
    users_index = []
    ages = []
    question_content = []
    locations = []
    # tu juz nie
    personal_questions_user = PersonalQuestionUser.objects.filter(user=request.user)
    mydata = UserData.objects.get(user=request.user)
    if not mydata.personality:
        display = False
    else:
        display = True
        if personal_questions_user:
            for p in personal_questions_user:
                answer_set = PersonalQuestionAnswer.objects.filter(questionID=str(p.questionID))
                question_set = PersonalQuestionContent.objects.filter(questionID=str(p.questionID)).values("content").all()
                if answer_set:
                    for usr in answer_set:
                        if str(usr.user) not in users_ids:
                            questions += [[str(usr.content)]]

                            users_ids += [(str(usr.user))]
                            question_content += [[q["content"] for q in question_set]]
                            # lokalizacja
                            locations += [float("{0:.2f}".format(distance_between(usr.user, request.user)))]

                            # sets
                            user_set = UserData.objects.filter(user=str(usr.user.id)).values("id", "description",
                                                                                             "photo",
                                                                                             "birth").all()
                            user_set2 = UserData.objects.filter(user=str(usr.user.id)).values("user_id").all()
                            # data from sets
                            descriptions += [' ' + q["description"] for q in user_set]
                            photos += [q["photo"] for q in user_set]
                            ages += [calculate_age(q["birth"]) for q in user_set]
                            users_index += [(q["user_id"]) for q in user_set2]
                        else:
                            for idu, u in enumerate(users_ids):
                                if str(usr.user) == u:
                                    questions[idu] += [(str(usr.content))]
                                    question_content[idu] += [q["content"] for q in question_set]

    formset_form = formset_factory(PersonalQuestionsForm, extra=len(users_ids))
    if len(users_ids) == 0:
        display = False
    formset = formset_form()
    return render(request, 'html_pages/view_answers.html',
                  {"display": display, "formset": formset, "question_content": question_content, "names": users_ids,
                   "user_index": users_index, "descriptions": descriptions, "questions": questions, "age": ages,
                   "img": photos, "local": locations, 'media_url': settings.STATIC_URL})
예제 #4
0
    def update(self):

        if functions.distance_between(self.rect,config.player.rect)> self.SENSES:
            if self.timetochangedirection <= 0:
                self.direction = direction.random()
            
            self.timeleft -= 1
            
        else:
            #ai.pathfind(self.rect, player.rect) #not implemented yet
            vector = [random.randint(0,self.SPEED*2)-self.SPEED,
                      random.randint(0,self.SPEED*2)-self.SPEED]
            self.move(vector)
예제 #5
0
    def update(self):

        if functions.distance_between(self.rect,
                                      data.player.rect) > self.SENSES:
            if self.timetochangedirection <= 0:
                self.direction = direction.random()

            self.timeleft -= 1

        else:
            self.move(
                direction.to_vector(
                    ai.pathfinding(self.rect, data.player.rect), self.SPEED))