Best Python code snippet using localstack_python
signals.py
Source:signals.py
1from django.contrib.auth.signals import user_logged_in, user_logged_out2from django.db.models.signals import post_save, post_delete3from django.dispatch.dispatcher import Signal4from django.dispatch import receiver5from actstream import action6from actstream.models import Action7from common.middleware import get_current_user8from website.models import Actor, Verb, Object, Post, SiteHeader, Welcome, Partner, Link, Resource, Video9from waterlevel.models import WaterLevelReport, WaterGate10from reporting.models import Report, Template11from reports.models import Event12from earlywarning.models import EarlyWarningReport13from automaticweathersystem.models import SensorReport14from weatherforecast.models import WeatherForecastReport15from disasterrehabilitation.models import EventAssessment16from reportaggregator.models import Source, Keyword17@receiver(user_logged_in)18def user_logged_in(user, **kwargs):19 """20 receive signals when user login21 """22 if not Actor.objects.filter(user=user).exists():23 Actor.objects.create(user=user)24 login_actor = Actor.objects.get(user=user)25 login_activity = Verb.objects.get(name='login')26 action.send(login_actor, verb=login_activity, description=login_activity.description)27@receiver(user_logged_out)28def user_logged_out(user, **kwargs):29 """30 receive signals when user logout31 """32 logout_actor = Actor.objects.get(user=user)33 logout_activity = Verb.objects.get(name='logout')34 action.send(logout_actor, verb=logout_activity, description=logout_activity.description)35@receiver(post_save, sender=WaterLevelReport)36def waterlevel_report_add_or_edit(sender, instance, **kwargs):37 """38 receive signals when user adding/editing WaterLevelReport39 """40 user = get_current_user()41 if kwargs.get('created', False):42 add_actor = Actor.objects.get(user=user)43 add_activity = Verb.objects.get(name='waterlevel_report_adding')44 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.watergate)45 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)46 else:47 edit_actor = Actor.objects.get(user=user)48 edit_activity = Verb.objects.get(name='sensor_report_adding')49 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.watergate)50 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)51@receiver(post_delete, sender=WaterLevelReport)52def waterlevel_report_delete(sender, instance, **kwargs):53 """54 receive signals when user deleting WaterLevelReport55 """56 user = get_current_user()57 delete_actor = Actor.objects.get(user=user)58 delete_activity = Verb.objects.get(name='waterlevel_report_deleting')59 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.watergate)60 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)61@receiver(post_save, sender=WaterGate)62def watergate_add_or_edit(sender, instance, **kwargs):63 """64 receive signals when user adding/editing WaterGate65 """66 user = get_current_user()67 if kwargs.get('raw', False): # dont trigger on fixture loaddata68 return False69 if kwargs.get('created', False):70 add_actor = Actor.objects.get(user=user)71 add_activity = Verb.objects.get(name='watergate_adding')72 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)73 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)74 else:75 edit_actor = Actor.objects.get(user=user)76 edit_activity = Verb.objects.get(name='wategate_editing')77 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)78 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)79@receiver(post_delete, sender=WaterGate)80def watergate_delete(sender, instance, **kwargs):81 """82 receive signals when user deleting WaterGate83 """84 user = get_current_user()85 delete_actor = Actor.objects.get(user=user)86 delete_activity = Verb.objects.get(name='watergate_deleting')87 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)88 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)89@receiver(post_save, sender=Event)90def event_reporting_add_or_edit(sender, instance, **kwargs):91 """92 receive signals when user adding/editing Event93 """94 user = get_current_user()95 if kwargs.get('created', False):96 add_actor = Actor.objects.get(user=user)97 add_activity = Verb.objects.get(name='event_report_adding')98 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.disaster)99 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)100 else:101 edit_actor = Actor.objects.get(user=user)102 edit_activity = Verb.objects.get(name='event_report_editing')103 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.disaster)104 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)105@receiver(post_delete, sender=Event)106def event_reporting_delete(sender, instance, **kwargs):107 """108 receive signals when user deleting Event109 """110 user = get_current_user()111 delete_actor = Actor.objects.get(user=user)112 delete_activity = Verb.objects.get(name='event_report_deleting')113 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.disaster)114 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)115@receiver(post_save, sender=EarlyWarningReport)116def early_warning_report_add_or_edit(sender, instance, **kwargs):117 """118 receive signals when user adding/editing EarlyWarningReport119 """120 user = get_current_user()121 122 if kwargs.get('created', False): 123 add_actor = Actor.objects.get(user=user)124 add_activity = Verb.objects.get(name='early_warning_report_adding')125 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)126 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)127 else:128 edit_actor = Actor.objects.get(user=user)129 edit_activity = Verb.objects.get(name='early_warning_report_editing')130 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)131 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)132@receiver(post_delete, sender=EarlyWarningReport)133def early_warning_report_delete(sender, instance, **kwargs):134 """135 receive signals when user deleting EarlyWarningReport136 """137 user = get_current_user()138 delete_actor = Actor.objects.get(user=user)139 delete_activity = Verb.objects.get(name='early_warning_report_deleting')140 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)141 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)142@receiver(post_save, sender=SensorReport)143def sensor_report_add_or_edit(sender, instance, **kwargs):144 """145 receive signals when user adding/editing SensorReport146 """147 user = get_current_user()148 149 if kwargs.get('created', False):150 add_actor = Actor.objects.get(user=user)151 add_activity = Verb.objects.get(name='sensor_report_adding')152 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.sensorstation)153 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)154 else:155 edit_actor = Actor.objects.get(user=user)156 edit_activity = Verb.objects.get(name='sensor_report_editing')157 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.sensorstation)158 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)159@receiver(post_delete, sender=SensorReport)160def sensor_report_delete(sender, instance, **kwargs):161 """162 receive signals when user deleting SensorReport163 """164 user = get_current_user()165 delete_actor = Actor.objects.get(user=user)166 delete_activity = Verb.objects.get(name='sensor_report_deleting')167 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.sensorstation)168 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)169@receiver(post_save, sender=WeatherForecastReport)170def weather_forcast_report_add_or_edit(sender, instance, **kwargs):171 """172 receive signals when user adding/editing WeatherForecastReport173 """174 user = get_current_user()175 if kwargs.get('created', False):176 add_actor = Actor.objects.get(user=user)177 add_activity = Verb.objects.get(name='weather_forecast_report_adding')178 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.city)179 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)180 else:181 edit_actor = Actor.objects.get(user=user)182 edit_activity = Verb.objects.get(name='weather_forecast_report_editing')183 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.city)184 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)185@receiver(post_delete, sender=WeatherForecastReport)186def weather_forcast_report_delete(sender, instance, **kwargs):187 """188 receive signals when user deleting WeatherForecastReport189 """190 user = get_current_user()191 delete_actor = Actor.objects.get(user=user)192 delete_activity = Verb.objects.get(name='weather_forecast_report_deleting')193 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.city)194 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)195@receiver(post_save, sender=Report)196def pusdalops_report_add_or_edit(sender, instance, **kwargs):197 """198 receive signals when user adding/editing Pusdalops Report199 """200 user = instance.author201 if kwargs.get('created', False):202 add_actor = Actor.objects.get(user=user)203 add_activity = Verb.objects.get(name='pusdalops_report_adding')204 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.type)205 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)206 else:207 edit_actor = Actor.objects.get(user=user)208 edit_activity = Verb.objects.get(name='pusdalops_report_editing')209 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.type)210 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)211@receiver(post_delete, sender=Report)212def pusdalops_report_delete(sender, instance, **kwargs):213 """214 receive signals when user deleting Pusdalops Report215 """216 user = instance.author217 delete_actor = Actor.objects.get(user=user)218 delete_activity = Verb.objects.get(name='pusdalops_report_deleting')219 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.type)220 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)221@receiver(post_save, sender=Template)222def pusdalops_template_add_or_edit(sender, instance, **kwargs):223 """224 receive signals when user adding/editing Pusdalops Template225 """226 user = get_current_user()227 if kwargs.get('raw', False): # dont trigger on fixture loaddata228 return False229 if kwargs.get('created', False):230 add_actor = Actor.objects.get(user=user)231 add_activity = Verb.objects.get(name='pusdalops_template_adding')232 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)233 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)234 else:235 edit_actor = Actor.objects.get(user=user)236 edit_activity = Verb.objects.get(name='pusdalops_template_editing')237 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)238 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)239@receiver(post_delete, sender=Template)240def pusdalops_template_delete(sender, instance, **kwargs):241 """242 receive signals when user deleting Pusdalops Template243 """244 user = get_current_user()245 delete_actor = Actor.objects.get(user=user)246 delete_activity = Verb.objects.get(name='pusdalops_template_deleting')247 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)248 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)249@receiver(post_save, sender=Post)250def website_post_add_or_edit(sender, instance, **kwargs):251 """252 receive signals when user adding/editing Post Website253 """254 user = instance.author255 256 if kwargs.get('created', False):257 add_actor = Actor.objects.get(user=user)258 add_activity = Verb.objects.get(name='website_post_adding')259 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)260 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)261 else:262 edit_actor = Actor.objects.get(user=user)263 edit_activity = Verb.objects.get(name='website_post_editing')264 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)265 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)266@receiver(post_delete, sender=Post)267def website_post_delete(sender, instance, **kwargs):268 """269 receive signals when user deleting Post Website270 """271 user = instance.author272 delete_actor = Actor.objects.get(user=user)273 delete_activity = Verb.objects.get(name='website_post_deleting')274 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)275 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)276@receiver(post_save, sender=SiteHeader)277def website_siteheader_add_or_edit(sender, instance, **kwargs):278 """279 receive signals when user adding/editing SiteHeader Website280 """281 user = get_current_user()282 if kwargs.get('created', False):283 add_actor = Actor.objects.get(user=user)284 add_activity = Verb.objects.get(name='website_siteheader_adding')285 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)286 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)287 else:288 edit_actor = Actor.objects.get(user=user)289 edit_activity = Verb.objects.get(name='website_siteheader_editing')290 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)291 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)292@receiver(post_delete, sender=SiteHeader)293def website_siteheader_delete(sender, instance, **kwargs):294 """295 receive signals when user deleting SiteHeader Website296 """297 user = get_current_user()298 delete_actor = Actor.objects.get(user=user)299 delete_activity = Verb.objects.get(name='website_siteheader_deleting')300 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)301 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)302@receiver(post_save, sender=Welcome)303def website_welcome_add_or_edit(sender, instance, **kwargs):304 """305 receive signals when user adding/editing Welcome Website306 """307 user = get_current_user()308 if kwargs.get('raw', False): # dont trigger on fixture loaddata309 return False310 if kwargs.get('created', False):311 add_actor = Actor.objects.get(user=user)312 add_activity = Verb.objects.get(name='website_welcome_adding')313 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)314 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)315 else:316 edit_actor = Actor.objects.get(user=user)317 edit_activity = Verb.objects.get(name='website_welcome_editing')318 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)319 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)320@receiver(post_delete, sender=Welcome)321def website_welcome_delete(sender, instance, **kwargs):322 """323 receive signals when user deleting Welcome Website324 """325 user = get_current_user()326 delete_actor = Actor.objects.get(user=user)327 delete_activity = Verb.objects.get(name='website_welcome_deleting')328 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)329 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)330@receiver(post_save, sender=Partner)331def website_partner_add_or_edit(sender, instance, **kwargs):332 """333 receive signals when user adding/editing Partner Website334 """335 user = get_current_user()336 if kwargs.get('created', False):337 add_actor = Actor.objects.get(user=user)338 add_activity = Verb.objects.get(name='website_partner_adding')339 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)340 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)341 else:342 edit_actor = Actor.objects.get(user=user)343 edit_activity = Verb.objects.get(name='website_partner_editing')344 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)345 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)346@receiver(post_delete, sender=Partner)347def website_partner_delete(sender, instance, **kwargs):348 """349 receive signals when user deleting Partner Website350 """351 user = get_current_user()352 delete_actor = Actor.objects.get(user=user)353 delete_activity = Verb.objects.get(name='website_partner_deleting')354 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)355 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)356@receiver(post_save, sender=Resource)357def website_resource_add_or_edit(sender, instance, **kwargs):358 """359 receive signals when user adding/editing Resource Website360 """361 user = get_current_user()362 if kwargs.get("created", False):363 add_actor = Actor.objects.get(user=user)364 add_activity = Verb.objects.get(name='website_resource_adding')365 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)366 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)367 else:368 edit_actor = Actor.objects.get(user=user)369 edit_activity = Verb.objects.get(name='website_resource_editing')370 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)371 action.send(add_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)372@receiver(post_delete, sender=Partner)373def website_resource_delete(sender, instance, **kwargs):374 """375 receive signals when user deleting Resource Website376 """377 user = get_current_user()378 delete_actor = Actor.objects.get(user=user)379 delete_activity = Verb.objects.get(name='website_resource_deleting')380 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)381 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)382@receiver(post_save, sender=Video)383def website_video_add_or_edit(sender, instance, **kwargs):384 """385 receive signals when user adding/editing Video Website386 """387 user = get_current_user()388 389 if kwargs.get("created", False):390 add_actor = Actor.objects.get(user=user) 391 add_activity = Verb.objects.get(name='website_video_adding')392 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)393 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)394 else:395 edit_actor = Actor.objects.get(user=user)396 edit_activity = Verb.objects.get(name='website_video_editing')397 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)398 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)399@receiver(post_delete, sender=Video)400def website_video_delete(sender, instance, **kwargs):401 """402 receive signals when user deleting Video Website403 """404 user = get_current_user()405 delete_actor = Actor.objects.get(user=user)406 delete_activity = Verb.objects.get(name='website_video_deleting')407 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.title)408 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)409@receiver(post_save, sender=EventAssessment)410def event_assessment_add_or_edit(sender, instance, **kwargs):411 """412 receive signals when user adding/editing Event Assessment Disaster Rehabilitation413 """414 user = get_current_user()415 416 if kwargs.get("created", False):417 add_actor = Actor.objects.get(user=user) 418 add_activity = Verb.objects.get(name='event_assessment_adding')419 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)420 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)421 else:422 edit_actor = Actor.objects.get(user=user)423 edit_activity = Verb.objects.get(name='event_assessment_editing')424 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)425 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)426@receiver(post_delete, sender=EventAssessment)427def event_assessment_delete(sender, instance, **kwargs):428 """429 receive signals when user deleting Event Assessment Disaster Rehabilitation430 """431 user = get_current_user()432 delete_actor = Actor.objects.get(user=user)433 delete_activity = Verb.objects.get(name='event_assessment_deleting')434 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)435 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)436@receiver(post_save, sender=Source)437def report_aggregator_source_add_or_edit(sender, instance, **kwargs):438 """439 receive signals when user adding/editing Source in Report Aggregator440 """441 user = get_current_user()442 443 if kwargs.get("created", False):444 add_actor = Actor.objects.get(user=user) 445 add_activity = Verb.objects.get(name='report_aggregator_source_adding')446 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)447 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)448 else:449 edit_actor = Actor.objects.get(user=user)450 edit_activity = Verb.objects.get(name='report_aggregator_source_editing')451 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)452 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)453@receiver(post_delete, sender=Source)454def report_aggregator_source_delete(sender, instance, **kwargs):455 """456 receive signals when user deleting Source in Report Aggregator457 """458 user = get_current_user()459 delete_actor = Actor.objects.get(user=user)460 delete_activity = Verb.objects.get(name='report_aggregator_source_deleting')461 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)462 action.send(delete_actor, verb=delete_activity, description=delete_activity.description, action_object=delete_object)463@receiver(post_save, sender=Keyword)464def report_aggregator_keyword_add_or_edit(sender, instance, **kwargs):465 """466 receive signals when user adding/editing Keyword in Report Aggregator467 """468 user = get_current_user()469 470 if kwargs.get("created", False):471 add_actor = Actor.objects.get(user=user) 472 add_activity = Verb.objects.get(name='report_aggregator_keyword_adding')473 add_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.keyword)474 action.send(add_actor, verb=add_activity, description=add_activity.description, action_object=add_object)475 else:476 edit_actor = Actor.objects.get(user=user)477 edit_activity = Verb.objects.get(name='report_aggregator_keyword_editing')478 edit_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.name)479 action.send(edit_actor, verb=edit_activity, description=edit_activity.description, action_object=edit_object)480@receiver(post_delete, sender=Keyword)481def report_aggregator_keyword_delete(sender, instance, **kwargs):482 """483 receive signals when user deleting Keyword in Report Aggregator484 """485 user = get_current_user()486 delete_actor = Actor.objects.get(user=user)487 delete_activity = Verb.objects.get(name='report_aggregator_keyword_deleting')488 delete_object = Object.objects.create(obj_id=instance.pk, obj_text=instance.keyword)...
clicks.py
Source:clicks.py
1from config import db_manager2from datetime import datetime3import json4import csv5def add_click(session_id, action, mode, metadata):6 timestamp = datetime.now()7 db_manager.insert("""8 INSERT INTO clicks (id, mode, action, metadata, timestamp) 9 VALUES ("{id}", "{mode}", "{action}", "{metadata}", "{timestamp}")10 """.format(action=action, id=session_id, timestamp=timestamp, metadata=metadata.replace('"', "'"), mode=mode))11def parse_clicks():12 clicks_query = db_manager.query("""13 SELECT id, action, metadata 14 FROM clicks15 WHERE mode = "evaluation"16 """)17 clicks = [{"add_activity": 0,18 "delete_activity": 0,19 "change_activities": 0,20 "change_travel_method": 0,21 "reorder_activities": 0,22 "change_duration": 0,23 "change_activities_done": 0,24 "update_window": 025 }, {"add_activity": 0,26 "delete_activity": 0,27 "change_activities": 0,28 "change_travel_method": 0,29 "reorder_activities": 0,30 "change_duration": 0,31 "change_activities_done": 0,32 "update_window": 033 }, {"add_activity": 0,34 "delete_activity": 0,35 "change_activities": 0,36 "change_travel_method": 0,37 "reorder_activities": 0,38 "change_duration": 0,39 "change_activities_done": 0,40 "update_window": 041 }]42 for c in clicks_query:43 itinNum = json.loads(c[2].replace("'", '"'))["itinNum"]44 clicks[itinNum][c[1]] += 145 with open('clicks.csv', 'w', newline='') as f:46 writer = csv.writer(f)47 writer.writerow(["", "add_activity",48 "delete_activity",49 "change_activities",50 "change_travel_method",51 "reorder_activities",52 "change_duration", "change_activities_done", "update_window"])53 for c in clicks:54 writer.writerow(["", c["add_activity"], c["delete_activity"],...
urls.py
Source:urls.py
1from django.urls import path2from . import views3urlpatterns = [4 path('', views.all_activities, name='activities'),5 path('activity_page/<str:key>/', views.activity_page, name='activity_page'),6 path('add_activity/', views.add_activity, name='add_activity'),7 path('edit_activity/<str:key>/', views.edit_activity, name='edit_activity'),8 path('delete_activity/<str:key>/', views.delete_activity, name='delete_activity'),9 path('add_booking_slot/<str:key>/', views.add_booking_slot, name='add_booking_slot'),10 path('delete_booking_slot/<str:key>/', views.delete_booking_slot, name='delete_booking_slot'),11 path('create_booking/<str:key>/', views.create_booking, name='create_booking'),...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!