Beispiel #1
0
    def save(self, *args, **kwargs):
        if not self.__member_has_open_reservations():
            raise DataError('Member has already booked a timeslot for this day.')

        if not self.__timeslot_is_available():
            raise DataError('The timeslot is already full')

        return super().save(*args, **kwargs)
Beispiel #2
0
    def save(self, *args, **kwargs):
        is_new = self._state.adding

        if is_new:
            # This is a CREATE operation

            # Check that the chat referenced does not contain more than 1 other user in the chat in the database.
            chat_users_in_chat = self.chat_id.chatuser_set.all()

            # Check that the chat you want to insert the chat user in is not already full
            if len(chat_users_in_chat) >= 2:
                raise DataError(
                    "Cannot assign this ChatUser instance to a Chat with pk %(pk)s because this \
					chat already contains at least 2 users (the chat is full)" %
                    {'pk': self.chat_id.pk})

            # Check that as a result of inserting the chat user instances you won't have
            # two chats in the database after calling save() that each have the 'same' chat users.
            #
            # For example:
            #	A chat with pk 16 with Joe and Jessica in the chat
            #	and another chat with pk 32 with Joe and Jessica again.
            #
            # This check is necessary as to not violate the business logic that there should
            # not be more than one chat between two different warframe accounts to capture the
            # idea of a sort of "unique chat area" that two warframe accounts use to chat between each other.

            if len(chat_users_in_chat) == 1:
                chat_user_in_chat = chat_users_in_chat[0]
                chat_user_wfa = chat_user_in_chat.warframe_account_id

                #print("chat_user_in_chat.warframe_account_id.pk: ")
                #print(chat_user_in_chat.warframe_account_id.pk)
                #print("self.warframe_account_id.pk:")
                #print(self.warframe_account_id.pk)
                #print("chat_user_in_chat.warframe_account_id.pk != (self.warframe_account_id.pk):")
                #print(chat_user_in_chat.warframe_account_id.pk != self.warframe_account_id.pk)

                if (chat_user_in_chat.warframe_account_id.pk !=
                    (self.warframe_account_id.pk)):
                    if (self._chat_between_wfa_already_exists(
                            chat_user_wfa, self.warframe_account_id)):
                        raise DataError("Attempted to add a chat user to a chat that would result " + \
                         "in duplicate chats between two particular WarframeAcccount instances.")
                else:
                    # chat_user_in_chat's warframe_account_id is the same as self.warframe_account_id
                    # meaning that after the save() there will be two warframe accounts in the same chat room.
                    # But since this case is handled by the 'no_duplicate_warframe_accounts_in_chat' constraint
                    # will just let the database constraint handle it.
                    pass
        else:
            # This is an update. Don't do anything on an update since a chat user cannot be updated
            raise ProgrammingError(
                "An attempt was made to update a ChatUser model. ChatUser should not and cannot be updated!"
            )

        super(ChatUser, self).save(*args, **kwargs)
Beispiel #3
0
    def save(self, *args, **kwargs):
        if not self.tracker.has_changed('household_id'):
            return super().save(*args, **kwargs)

        if not self.__household_has_vacancies():
            raise DataError('Household is already full')

        if self.household_id and self.student_team_id:
            raise DataError(
                'One cannot join both a household and a student team')

        # we're in the clear
        super().save(*args, **kwargs)
 def invite_user(self, inviter_user, invitee_user, allow_trials=False):
     if not self.is_user_member(inviter_user):
         raise PermissionDenied("Inviter is not a member of the group")
     if self.is_user_member(invitee_user):
         raise DataError("User is already a member of this group")
     if self.has_user_been_invited(invitee_user):
         raise DataError("User has already been invited")
     invite = GroupInvite(group=self,
                          invitee=invitee_user,
                          inviter=inviter_user,
                          can_trial=allow_trials,
                          invite_date_time=timezone.now())
     invite.save()
     return invite
Beispiel #5
0
    def _map_entity(self, entity):
        new_key = Key.from_path(self.to_kind,
                                entity.key().id_or_name(),
                                namespace=self.to_namespace)

        parent = entity.parent()
        if parent:
            # If the entity has an ancestor then we need to make sure that that ancestor exists in
            # the new namespace as well
            new_parent_key = Key.from_path(parent.kind(),
                                           parent.is_or_name(),
                                           namespace=self.to_namespace)
            new_parent_exists = Get([new_parent_key])[0]
            if not new_parent_exists:
                raise DataError(
                    "Trying to copy entity with an ancestor (%r) to a new namespace but the "
                    "ancestor does not exist in the new namespace. Copy the ancestors first."
                    % entity.key())

        def txn():
            existing = Get([new_key])[0]
            if existing and not self.overwrite_existing:
                return
            if isinstance(entity.key().id_or_name(), (int, long)):
                reserve_id(self.to_kind,
                           entity.key().id_or_name(), self.to_namespace)
            new_entity = clone_entity(entity, new_key)
            Put(new_entity)

        RunInTransaction(txn)
Beispiel #6
0
 def save(self, *args, **kwargs):
     """Override save method to update unique slug based on the other fields."""
     slug = slugify(self.name)
     if Tea.objects.filter(slug=slug).exclude(id=self.id).exists():
         raise DataError('Tea with slug: {} already exists'.format(slug))
     else:
         self.slug = slug
     super().save(*args, **kwargs)
Beispiel #7
0
 def save(self, *args, **kwargs):
     """Override save method to update unique slug based on the other fields."""
     slug = self.platform.slug + '-' + slugify(self.name)
     if self.edition:
         slug = slug + '-' + slugify(self.edition)
     if Game.objects.filter(slug=slug).exclude(id=self.id).exists():
         raise DataError('Game with slug %s already exists' % slug)
     super().save(*args, **kwargs)
 def join_group(self, user, can_trial=False):
     if not self.is_user_member(user):
         membership = GroupMembership(user=user,
                                      group=self,
                                      date_joined=timezone.now(),
                                      can_trial=can_trial)
         membership.save()
     else:
         raise DataError("User is already a member of this group.")
Beispiel #9
0
 def get_random(kind):
     pictures = StockPicture.objects.filter(kind=kind)
     count = pictures.count()
     if count == 0:
         raise DataError(
             'No stock pictures with the kind "{}" in database'.format(
                 kind))
     i = random.randrange(count)
     return pictures[i]
Beispiel #10
0
    def save(self, *args, **kwargs):
        self.end_time = self.start_time + timedelta(hours=LENGTH_OF_TIMESLOT)

        slug = [
            str(self.area.id),
            self.start_time.strftime(SLUG_STRFTIME_FORMAT),
            self.end_time.strftime(SLUG_STRFTIME_FORMAT),
        ]
        self.slug = "-".join(slug)

        if (self.start_time.hour % LENGTH_OF_TIMESLOT != 0):
            raise DataError('Timeslots must be divisible by LENGTH_OF_TIMESLOT')

        if (self.start_time.minute != 0 or self.start_time.second != 0):
            raise DataError('Timeslots must start at the beginning of the hour')


        return super().save(*args, **kwargs)
 def set_has_default_choices(self, default_choices_requested):
     if Proposal.objects.filter(proposal_group=self,
                                state=ProposalState.PUBLISHED).count() == 0:
         self.group_default_choices = default_choices_requested
         self.save()
     else:
         raise DataError(
             'Default choices cannot be set as Proposal Group has published proposals.'
         )
Beispiel #12
0
 def recount(self):
     bl = 0
     for t in self.transations.order_by('trans_date', 'type'):
         bl += (t.type == choices.TRANS_TYPE_DEPOSIT and 1 or -1) * t.amount
         if bl < 0:
             raise DataError('余额不足')
         t.balance = bl
         t.save()
     self.balance = bl
     self.save()
Beispiel #13
0
def join_alt_fields(apps, schema_editor):
    for model in apps.app_configs["enhydris"].get_models():
        alt_fields = [
            field for field in model._meta.get_fields() if field.name.endswith("_alt")
        ]
        if not alt_fields:
            continue
        for obj in model.objects.all():
            for alt_field in alt_fields:
                field = [
                    field
                    for field in model._meta.get_fields()
                    if field.name == alt_field.name[:-4]
                ][0]
                value = getattr(obj, field.name)
                value_alt = getattr(obj, alt_field.name)
                if (not value_alt) or (value == value_alt):
                    # The _alt field is empty or the same as the main field, do nothing
                    continue
                elif not value:
                    # The main field is empty, set it to the _alt field
                    setattr(obj, field.name, value_alt)
                else:
                    # Both are nonempty, join them
                    if type(field).__name__ == "CharField":
                        fmt = "{} [{}]"
                    elif type(field).__name__ == "TextField":
                        fmt = "{}" + SEPARATOR + "{}"
                    else:
                        raise Exception(
                            "Field {}.{} is neither a CharField nor a TextField".format(
                                model.__name__, field.name
                            )
                        )
                    setattr(obj, field.name, fmt.format(value, value_alt))

                # Set the alt field to empty. Then, if we come again to the same object
                # (e.g. when iterating in Gentity, and then again in Station), there
                # won't be chaos.
                setattr(obj, alt_field.name, "")

                try:
                    obj.save()
                except DataError as e:
                    raise DataError(
                        "Couldn't save object {} (id={}); perhaps {}='{}' is too long. "
                        "Original message: {}".format(
                            model.__name__,
                            obj.id,
                            field.name,
                            getattr(obj, field.name),
                            str(e),
                        )
                    )
    def publish(self, default_group_to_these_choices=False):
        if self.proposal_group:
            if default_group_to_these_choices:
                if self.can_default_group_to_these_choices:
                    # set the group so it knows it has a default
                    self.proposal_group.set_has_default_choices(True)
                    # move all ON_HOLD proposals to archived
                    on_hold_proposals = Proposal.objects.filter(
                        proposal_group=self.proposal_group,
                        state=ProposalState.ON_HOLD)
                    for on_hold_proposal in on_hold_proposals:
                        on_hold_proposal.archive()

                else:
                    raise DataError(
                        'Default choices cannot be set as Proposal Group has published proposals.'
                    )
            else:
                if self.proposal_group.has_default_group_proposal_choices:
                    # deactivate all the existing choices on the proposal
                    (ProposalChoice.objects.filter(
                        proposal=self, deactivated_date__isnull=True).update(
                            deactivated_date=timezone.now()))
                    # copy from first published proposal
                    copy_from_proposal = (Proposal.objects.filter(
                        proposal_group=self.proposal_group,
                        state=ProposalState.PUBLISHED).first())
                    if not copy_from_proposal:
                        raise DataError("No default data found")
                    cloned_choices = ProposalChoice.objects.filter(
                        proposal=copy_from_proposal,
                        deactivated_date__isnull=True)
                    for choice in cloned_choices:
                        # use Django method for cloning objects
                        choice.pk = None
                        choice.proposal = self
                        choice.current_consensus = False
                        choice.activated_date = timezone.now()
                        choice.save()
        self.updateState(ProposalState.PUBLISHED)
Beispiel #15
0
 def post(self, request, *args, **kwargs):
     try:
         with transaction.atomic():
             if ("basket_id" not in request.session.keys()
                     or not request.user.is_authenticated):
                 return HttpResponseRedirect(
                     reverse_lazy("eboutic:main",
                                  args=self.args,
                                  kwargs=kwargs))
             b = Basket.objects.filter(
                 id=request.session["basket_id"]).first()
             if (b is None or b.items.filter(
                     type_id=settings.SITH_COUNTER_PRODUCTTYPE_REFILLING).
                     exists()):
                 return HttpResponseRedirect(
                     reverse_lazy("eboutic:main",
                                  args=self.args,
                                  kwargs=kwargs))
             c = Customer.objects.filter(user__id=b.user.id).first()
             if c is None:
                 return HttpResponseRedirect(
                     reverse_lazy("eboutic:main",
                                  args=self.args,
                                  kwargs=kwargs))
             kwargs["not_enough"] = True
             if c.amount < b.get_total():
                 raise DataError(
                     _("You do not have enough money to buy the basket"))
             else:
                 eboutic = Counter.objects.filter(type="EBOUTIC").first()
                 for it in b.items.all():
                     product = eboutic.products.filter(
                         id=it.product_id).first()
                     Selling(
                         label=it.product_name,
                         counter=eboutic,
                         club=product.club,
                         product=product,
                         seller=c.user,
                         customer=c,
                         unit_price=it.product_unit_price,
                         quantity=it.quantity,
                         payment_method="SITH_ACCOUNT",
                     ).save()
                 b.delete()
                 kwargs["not_enough"] = False
                 request.session.pop("basket_id", None)
     except DataError as e:
         kwargs["not_enough"] = True
     return self.render_to_response(self.get_context_data(**kwargs))
Beispiel #16
0
def create_user(request):
    try:
        serializer = CustomerSerializer(data=request.data)
        if serializer.is_valid():
            for instance in Customer.objects.all():
                if instance.email == serializer.data["email"]:
                    raise DataError("Email id already exists")
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response({"message": serializer.errors},
                        status=status.HTTP_400_BAD_REQUEST)
    except Exception as err:
        return Response({'message': str(err)},
                        status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 def remove_member(self, user):
     if user == self.owned_by:
         raise PermissionDenied(
             "Cannot remove the owner of the proposal group from the group."
         )
     # removing members - need to remove the votes too!
     try:
         removed_membership = GroupMembership.objects.get(group=self,
                                                          user=user)
         self.deactivate_votes_for_user_in_group(user)
         removed_membership.delete()
     except GroupMembership.DoesNotExist:
         raise DataError(
             "User is not a member of the group and cannot be removed")
 def new_proposal(proposal_name="only a test",
                  date_proposed=None,
                  proposal_description="yes, this is only a test",
                  proposal_group=None,
                  owned_by=None):
     if not date_proposed:
         date_proposed = timezone.now()
     if owned_by is None:
         raise DataError("Owned by must be set for proposal creation.")
     return Proposal.objects.create(
         proposal_name=proposal_name,
         date_proposed=date_proposed,
         proposal_description=proposal_description,
         owned_by=owned_by,
         proposal_group=proposal_group)
Beispiel #19
0
    def save(self, *args, **kwargs):
        try:
            if (settings.DISABLE_CLOCK_CHECK == True):
                super(Event, self).save(*args, **kwargs)
        except:
            pass
        last_event = self.last_event(self.user)
        if last_event != None:
            last_event = last_event.event
        if self.id == None and not self.event in self.REQUIRED_EVENT[
                last_event]:
            raise DataError(
                'To "%s" you must "%s" first and not "%s"' %
                (self.event, self.REQUIRED_EVENT[last_event], last_event))

        super(Event, self).save(*args, **kwargs)
Beispiel #20
0
def add_hand(sithid, recruitid):
    try:
        sith_db = SithDB()
        sith = sith_db.get_by_id(sithid)
        sith_db.add_hand(sith)
        recruit_db = RecruitDB()
        recruit = recruit_db.get_by_id(recruitid)
        mail = Mail('*****@*****.**', 'grand.sith1')
        mail.send(msg='YOU ARE HAND NOW!', to_addr=recruit.email)
        mail.close()
        recruit.delete()
        return redirect('/sith/%s' % sithid)
    except ValidationError:
        raise ValidationError('Too much hands')
    except DataError:
        raise DataError('Something wrong with mail')
Beispiel #21
0
    def get(cls, player, game):
        '''
        Fetch (or create fromd efaults) the rating for a given player at a game
        and perform some quick data integrity checks in the process.

        :param player: a Player object
        :param game:   a Game object
        '''
        TS = TrueskillSettings()

        try:
            r = Rating.objects.get(player=player, game=game)
        except ObjectDoesNotExist:
            r = Rating.create(player=player, game=game)
        except MultipleObjectsReturned:
            raise IntegrityError(
                "Integrity error: more than one rating for {} at {}".format(
                    player.name_nickname, game.name))

        if not (isclose(r.trueskill_mu0, TS.mu0, abs_tol=FLOAT_TOLERANCE) and
                isclose(r.trueskill_sigma0, TS.sigma0, abs_tol=FLOAT_TOLERANCE)
                and isclose(
                    r.trueskill_delta, TS.delta, abs_tol=FLOAT_TOLERANCE)
                and isclose(r.trueskill_beta,
                            game.trueskill_beta,
                            abs_tol=FLOAT_TOLERANCE)
                and isclose(r.trueskill_tau,
                            game.trueskill_tau,
                            abs_tol=FLOAT_TOLERANCE)
                and isclose(
                    r.trueskill_p, game.trueskill_p, abs_tol=FLOAT_TOLERANCE)):
            SettingsWere = "µ0: {}, σ0: {}, ß: {}, δ: {}, τ: {}, p: {}".format(
                r.trueskill_mu0, r.trueskill_sigma0, r.trueskill_delta,
                r.trueskill_beta, r.trueskill_tau, r.trueskill_p)
            SettingsAre = "µ0: {}, σ0: {}, ß: {}, δ: {}, τ: {}, p: {}".format(
                TS.mu0, TS.sigma0, TS.delta, game.trueskill_beta,
                game.trueskill_tau, game.trueskill_p)
            raise DataError(
                "Data error: A trueskill setting has changed since the last rating was saved. They were ({}) and now are ({})"
                .format(SettingsWere, SettingsAre))
            # TODO: Issue warning to the registrar more cleanly than this
            # Email admins with notification and suggested action (fixing settings or rebuilding ratings).
            # If only game specific settings changed on that game is impacted of course.
            # If global settings are changed all ratings are affected.

        return r
 def test_data_error(self):
     # Verify that a DataError exception when calling save() is propertly
     # propagated.
     msg = EmailMessage()
     msg["From"] = "*****@*****.**"
     msg["Subject"] = "Fake Subject"
     msg["Message-ID"] = "<dummy>"
     msg["Date"] = "Fri, 02 Nov 2012 16:07:54"
     msg.set_payload("Fake Message")
     email = mock.Mock()
     email.save.side_effect = DataError("test error")
     with mock.patch("hyperkitty.lib.incoming.Email") as Email:
         Email.return_value = email
         filter_mock = mock.Mock()
         filter_mock.exists.return_value = False
         Email.objects.filter.return_value = filter_mock
         self.assertRaises(ValueError, add_to_list, "example-list", msg)
def feed_from_name(request, url_name):
    results = Feed.objects.filter(url_name=url_name).prefetch_related(
        "embeddedasset_set", "imageasset_set", "textasset_set")

    if results.count() == 0:
        messages.add_message(request, messages.ERROR,
                             "There is no feed called " + url_name + ".")
        return redirect("feeds")

    if results.count() > 1:
        raise DataError("Multiple feeds with the same url_name")

    this_feed = results.first()

    image_assets = this_feed.imageasset_set.all()
    embedded_assets = this_feed.embeddedasset_set.all()
    text_assets = this_feed.textasset_set.all()

    # Add all assets to list and sort by importance
    my_assets = []
    for i in image_assets:
        my_assets.append((i, AssetTypes.IMAGE, i.created_at))
    for e in embedded_assets:
        my_assets.append((e, AssetTypes.EMBEDDED, e.created_at))
    for t in text_assets:
        my_assets.append((t, AssetTypes.TEXT, t.created_at))
    my_assets.sort(key=lambda a: a[2], reverse=True)

    color_in_rgba = view_functions.generate_logo_rgba(this_feed.brand_color_1,
                                                      False)
    hover_in_rgba = view_functions.generate_logo_rgba(this_feed.brand_color_1,
                                                      True)

    return render(
        request,
        "feed.html",
        {
            "feed": this_feed,
            "assets": my_assets,
            "logo_custom_color": color_in_rgba,
            "logo_hover_color": hover_in_rgba,
        },
    )
Beispiel #24
0
    def validate(self, *args, **kwargs):
        if self.validated:
            raise DataError(_("Invoice already validated"))
        from counter.models import Customer

        if not Customer.objects.filter(user=self.user).exists():
            number = Customer.objects.count() + 1
            Customer(
                user=self.user,
                account_id=Customer.generate_account_id(number),
                amount=0,
            ).save()
        eboutic = Counter.objects.filter(type="EBOUTIC").first()
        for i in self.items.all():
            if i.type_id == settings.SITH_COUNTER_PRODUCTTYPE_REFILLING:
                new = Refilling(
                    counter=eboutic,
                    customer=self.user.customer,
                    operator=self.user,
                    amount=i.product_unit_price * i.quantity,
                    payment_method="CARD",
                    bank="OTHER",
                    date=self.date,
                )
                new.save()
            else:
                product = Product.objects.filter(id=i.product_id).first()
                new = Selling(
                    label=i.product_name,
                    counter=eboutic,
                    club=product.club,
                    product=product,
                    seller=self.user,
                    customer=self.user.customer,
                    unit_price=i.product_unit_price,
                    quantity=i.quantity,
                    payment_method="CARD",
                    is_validated=True,
                    date=self.date,
                )
                new.save()
        self.validated = True
        self.save()
def restore_code_description(apps, schema_editor):
    CasingCode = apps.get_model('wells', 'CasingCode')
    CasingMaterialCode = apps.get_model('wells', 'CasingMaterialCode')
    Casing = apps.get_model('wells', 'Casing')

    casing_code = CasingCode.objects.get(code='STL_REM')

    casing_material = CasingMaterialCode(code='STL_PUL_OT',
                                         description='Steel pulled out',
                                         display_order=20)
    casing_material.save()

    for casing in Casing.objects.filter(casing_code=casing_code):
        if casing.casing_material:
            raise DataError('Was not expecting to find casing code: {}'.format(
                casing.casing_code))
        casing.casing_material = casing_material
        casing.casing_code = None
        casing.save()

    casing_code.delete()
Beispiel #26
0
def update_review_fields(lesson, isCorrect):
    """ Update lesson fields relating to reviews """

    now = timezone.now()
    if lesson.next_review_time > now:
        raise DataError('The lesson is not available for review yet.')
    if isCorrect:
        lesson.review_correct += 1
    else:
        lesson.review_incorrect += 1
    lesson.review_stage = new_review_stage(lesson, isCorrect)
    lesson.next_review_time = nearest_hour(
        now + nextReviewTimedeltaTable[lesson.review_stage]
    )
    lesson.save(update_fields=[
        'review_correct',
        'review_incorrect',
        'review_stage',
        'next_review_time',
    ])
    print(f'Updated lesson { lesson.id }')
Beispiel #27
0
    def calc(self, source_clause, source_data):

        with connection.cursor() as cursor:
            sql = self._SQL % (source_clause, self.code)
            try:
                cursor.execute(sql, tuple(source_data))
            except Exception as exc:
                msg = ("Error executing rule %s\n" % self.name + str(exc) +
                       '\n\n in sql:\n\n' + sql)
                raise DataError(msg)
            findings = cursor.fetchone()
        limitation = dict(
            zip(('end_date', 'normal', 'description', 'explanation'),
                findings[2:]))
        if (not limitation['end_date']) and (not limitation['description']):
            limitation = None
        return {
            'eligible': findings[0],
            'explanation': findings[1],
            'limitation': limitation
        }
Beispiel #28
0
def modifyUserInfo(request):
    """
    修改用户个人信息接口
    只能修改 昵称, 性别, 简介, 头像
    :param request:
    :return:
    """
    resp = {
        'status': 1,
        'msg': '',
    }
    try:
        nickname = request.POST.get('nickname')
        gender = request.POST.get('gender')
        desc = request.POST.get('desc')
        head_img = request.FILES.get('head-img')
        # 判断是否有空的数据
        if not all((nickname, gender)):
            raise DataError('数据不能为空!')

        user = request.user
        user.nickname = nickname
        user.gender = gender
        user.desc = desc

        if head_img:
            user.avatar = head_img

        user.save()
        resp['status'] = 1
        resp['msg'] = '修改信息成功'
    except KeyError:
        resp['status'] = 2
        resp['msg'] = '不合法的参数!'
        return JsonResponse(status=400, data=resp)  # 这写法有点傻逼,后期优化下
    except DataError as e:
        resp['status'] = 2
        resp['msg'] = str(e)
        return JsonResponse(status=400, data=resp)  # 这写法有点傻逼,后期优化下
    return JsonResponse(resp)
def image_asset(request, url_uuid, file_name):
    results = ImageAsset.objects.filter(img=url_uuid + "/" + file_name)

    if results.count() == 0:
        messages.add_message(request, messages.ERROR,
                             "There is no asset at this URL.")
        return redirect("index")

    if results.count() > 1:
        raise DataError("Multiple assets with the same filename")

    image = results.first()

    return render(
        request,
        "asset.html",
        {
            "image": image,
            "page_title": image.title,
            "show_back_to_home": True
        },
    )
Beispiel #30
0
    def _chat_between_wfa_already_exists(self, warframe_account_one,
                                         warframe_account_two):
        '''Check if there already exists a chat between two warframe accounts. If they do
		exist in the chat, return True. False otherwise.
		'''

        chat_user_m = apps.get_model(app_label='chat', model_name='chatuser')

        #get the chat ids that 'warframe_account_one' and 'warframe_account_two' are in
        wfa_one_chats_in_ids = chat_user_m.objects.filter(
            warframe_account_id=warframe_account_one).values_list('chat_id',
                                                                  flat=True)
        wfa_two_chats_in_ids = chat_user_m.objects.filter(
            warframe_account_id=warframe_account_two).values_list('chat_id',
                                                                  flat=True)

        wfa_one_chats_in_ids = list(wfa_one_chats_in_ids)
        wfa_two_chats_in_ids = list(wfa_two_chats_in_ids)

        #chat ids that wfa_one and wfa two have been in
        duplicate_chat_ids = self._find_duplicates_from_nums(
            wfa_one_chats_in_ids + wfa_two_chats_in_ids)

        #since two warframe accounts can ever be in one chat, and the same pair
        #of warframe accounts cannot exist in more than 1 chat, duplicate_chat_ids should
        #return only one chat if the two warframe accounts are in a chat.

        if len(duplicate_chat_ids) == 0:
            return False
        elif len(duplicate_chat_ids) == 1:
            return True
        else:
            raise DataError(
                "Detected multiple chats that contain the same pair of warframe accounts (\
				warframe_account_one and warframe_account_two). Please check the integrity of your database with regards to 'duplicate chats'!"
            )