Example #1
0
    def add_tag_records(self, tags, user_id, brab_id):
        #        Delete existing tag links
        Tag_to_brab.objects.filter(brab_id=brab_id).delete()
        #        Re-create tag links based on the updated information in the POST
        tag_count = 0
        for tag_text in tags:
            tag_count = tag_count + 1
            existing_tags = Tag.objects.filter(tag__exact=tag_text)
            if not existing_tags:
                tag_object = Tag(auth_user_id=user_id,
                                 tag=tag_text,
                                 visible=True)
                tag_object.save()
                if not Tag_to_brab.objects.filter(brab_id=brab_id,
                                                  tag_id=tag_object.pk):
                    tag_link = Tag_to_brab(auth_user_id=user_id,
                                           brab_id=brab_id,
                                           tag_id=tag_object.pk)
                    tag_link.save()
            else:
                existing_tag = Tag.objects.get(tag__exact=tag_text)
                tag_link = Tag_to_brab(auth_user_id=user_id,
                                       brab_id=brab_id,
                                       tag_id=existing_tag.pk)
                tag_link.save()

        return tag_count
Example #2
0
    def add_tag_records(self, tags, user_id, brab_id):
        tag_count = 0
        for tag_text in tags:
            tag_count = tag_count + 1
            existing_tags = Tag.objects.filter(tag__exact=tag_text)
            if not existing_tags:
                tag_object = Tag(auth_user_id = user_id, tag = tag_text, visible = True)
                tag_object.save()
                tag_link = Tag_to_brab(auth_user_id = user_id, brab_id = brab_id, tag_id = tag_object.pk)
            else:
                existing_tag = Tag.objects.get(tag__exact=tag_text)
                tag_link = Tag_to_brab(auth_user_id = user_id, brab_id = brab_id, tag_id = existing_tag.pk)

            tag_link.save()

        return tag_count
Example #3
0
    def add_tag_records(self, tags, user_id, brab_id):
    #        Delete existing tag links
        Tag_to_brab.objects.filter(brab_id = brab_id).delete()
    #        Re-create tag links based on the updated information in the POST
        tag_count = 0
        for tag_text in tags:
            tag_count = tag_count + 1
            existing_tags = Tag.objects.filter(tag__exact=tag_text)
            if not existing_tags:
                tag_object = Tag(auth_user_id = user_id, tag = tag_text, visible = True)
                tag_object.save()
                if not Tag_to_brab.objects.filter(brab_id = brab_id, tag_id = tag_object.pk):
                    tag_link = Tag_to_brab(auth_user_id = user_id, brab_id = brab_id, tag_id = tag_object.pk)
                    tag_link.save()
            else:
                existing_tag = Tag.objects.get(tag__exact=tag_text)
                tag_link = Tag_to_brab(auth_user_id = user_id, brab_id = brab_id, tag_id = existing_tag.pk)
                tag_link.save()

        return tag_count
Example #4
0
    def add_tag_records(self, tags, user_id, brab_id):
        tag_count = 0
        for tag_text in tags:
            tag_count = tag_count + 1
            existing_tags = Tag.objects.filter(tag__exact=tag_text)
            if not existing_tags:
                tag_object = Tag(auth_user_id=user_id,
                                 tag=tag_text,
                                 visible=True)
                tag_object.save()
                tag_link = Tag_to_brab(auth_user_id=user_id,
                                       brab_id=brab_id,
                                       tag_id=tag_object.pk)
            else:
                existing_tag = Tag.objects.get(tag__exact=tag_text)
                tag_link = Tag_to_brab(auth_user_id=user_id,
                                       brab_id=brab_id,
                                       tag_id=existing_tag.pk)

            tag_link.save()

        return tag_count