Ejemplo n.º 1
0
def __add_report_tags(report, recipients):
    """
        Add tags to report based on provider, subject etc ...

        :param `abuse.models.Report` report: A `abuse.models.Report` instance
        :param list recipients: The list of recipients
    """
    tags = database.get_tags(report.provider, recipients, report.subject, report.body)

    for tag in tags:
        if tag.tagType == 'Report':
            report.tags.add(tag)
Ejemplo n.º 2
0
def __get_attributes_based_on_tags(report, recipients):
    """
        Get specific attributes based on provider's tags

        :param `abuse.models.Report` report: A `abuse.models.Report` instance
        :param list recipients: The list of recipients
        :rtype: tuple
        :returns: tuple of bool (autoarchive, attach_only, no_phishtocheck)
    """
    autoarchive = attach_only = no_phishtocheck = False
    tags = database.get_tags(report.provider, recipients, report.subject, report.body)

    for tag in tags:
        if tag.tagType == 'Provider':
            if tag.name == settings.TAGS['autoarchive']:
                autoarchive = True
            if tag.name == settings.TAGS['attach_only']:
                attach_only = True
            if tag.name == settings.TAGS['no_phishtocheck']:
                no_phishtocheck = True

    return autoarchive, attach_only, no_phishtocheck
Ejemplo n.º 3
0
async def get_tags(request):
    try:
        request_body = request.json
    except Exception as e:
        return error(TMVException.ID_PARSE_JSON,
                     'Couldn\'t parse request body as JSON')

    try:
        verify_input(request_body, [{
            'name': 'tags',
            'required': True,
            'type': 'qtag[]',
            'empty': False
        }])

        multi = 'multi' in request_body['tags']
        value = 'value' in request_body['tags']
        retval = database.get_tags(multi, value)
        return json({'response': retval})
    except TMVException as e:
        return error(e.error_id, e.error_msg)
    except Exception as e:
        return unknown_error(e)
Ejemplo n.º 4
0
 def test_get_tags(self):
     tags = get_tags(cursor)
     self.assertEqual(len(tags), 4)
Ejemplo n.º 5
0
def all_tags():
    cur = get_db().cursor()
    return jsonify(get_tags(cur))
Ejemplo n.º 6
0
async def tags():
    return get_tags().all()
def check_links(show = "all"):
	
	main_tags = database.get_tags()
	main_random_images = database.get_image_for_every_main_tag()		

	for main_tag in main_tags:
		images = database.get_images_by_tag({'main_tag': main_tag})
					
		#If the main_tag has images in it
		if (len(images) >= 1):
			print("\n" + main_tag + ": " + str( len(images) ) + " Total Images"),

			#Did the main_tag return at least 1 random image
			try:
				#If no random images are returned there will be no key in 'main_random_images' 
				#And this will fall through to missing a random/carousel image
				main_random_images[main_tag]
				print ("(Good)")

				sub_tags = database.get_sub_tags(main_tag)
				sub_random_images = database.get_image_for_each_sub_tag(main_tag)					
			
				#Now find out if the sub_tags with images each have a carousel image
				for sub_tag in sub_tags:
					sub_images = database.get_images_by_tag({'main_tag': sub_tag[0], 'sub_tag': sub_tag[1]})						

					if len(sub_images) >= 1:							
						print( "\t\t" +  sub_tag[1] +  ": " +  str( len(sub_images)) + " Images"),
						try: 								
							sub_random_images[sub_tag[1]]
							print("(Good)")

							event_tags = database.get_event_tags()							
							event_random_images = database.get_image_for_each_event_tag(sub_tag[1])								
							misc_count = database.get_misc_count_by_tag({'main_tag': sub_tag[0], 'sub_tag': sub_tag[1]})
							misc_random = database.get_image_for_misc_sub_tag(sub_tag[0], sub_tag[1])

							if misc_count >= 1:
								print ( "\t\t\t" + "Misc: " + str(misc_count)  ),
								if len(misc_random) >= 1:
									print("(Good)")
								else:
									print("(Missing Carousel)")


							for event_main_tag, event_sub_tag, event_tag in event_tags:									
								if event_sub_tag == sub_tag[1]:
									event_images = database.get_images_by_tag( {'main_tag': sub_tag[0], 'sub_tag': sub_tag[1], 'event_tag': event_tag} )
									
									if len(event_images) >= 1:
										print ("\t\t\t" + event_tag + ": " + str( len(event_images) ) ),

										try:
											event_random_images[event_tag]
											print("(Good)")
										except:
											print("(Missing Carousel)")
										

						except:
							print("(Missing Carousel)")


			except:
				print ("- Missing Carousel")