Exemplo n.º 1
0
 def save_model(self, request, obj, form, change):
     # Overwritten to send email whenever a car panel is added/changed from admin panel.
     obj.name = capitalize_words(obj.name)
     obj.save()
     add_or_change = 'changed' if change else 'added'
     from core.tasks import send_custom_notification_task
     send_custom_notification_task.delay(
         'OPS_MODEL_ADD_CHANGE_EMAIL', {
             'model': 'CarPanel',
             'updated_by': request.user.name,
             'id': obj.id,
             'add_or_change': add_or_change
         })
Exemplo n.º 2
0
 def as_tuple(self):
     return tuple([utils.capitalize_words(self.name), self.place, self.time, self.source, self.url, self.info, self.style, self.is_free])
Exemplo n.º 3
0
 def save_model(self, request, obj, form, change):
     obj.name = capitalize_words(obj.name)
     obj.save()
Exemplo n.º 4
0
        really_new_events = []

        print "\n- updated parties: "
        for p in new_events:
            # we check for renaming, redating and replacing, if more than one changed then the party will be cancelled and recreated instead of just updated
            (possible_match, possible_dead_db_events) = check_renaming(p, possible_dead_db_events)
            if not possible_match:
                (possible_match, possible_dead_db_events) = check_redating(p, possible_dead_db_events)
                if not possible_match:
                    (possible_match, possible_dead_db_events) = check_replacing(p, possible_dead_db_events)
            if possible_match:
                print p.name.__repr__()
                print "  - %s %s possibly match with party %s" % (p.time, utils.encode_null(p.name), possible_match)
                print (
                    "update events set name =%s, place= %s, time_start = %s, updated = %s where id = %s"
                    % (utils.capitalize_words(p.name), p.place, p.time, datetime.now(), possible_match)
                )
                cursor.execute(
                    "update events set name =%s, place= %s, time_start = %s, updated = %s where id = %s",
                    (utils.capitalize_words(p.name), p.place, p.time, datetime.now(), possible_match),
                )
                set_location(cursor, possible_match, p.place)
            else:
                really_new_events.append(p)

        print "\n- cancelled parties:"
        for par in [p for p in possible_dead_db_events if p[3] >= datetime.now()]:
            print "  - %s" % str(par)
            print ("update events set cancelled = true, updated = %s where id = %s" % (datetime.now(), par[0]))
            cursor.execute("update events set cancelled = true, updated = %s where id = %s", (datetime.now(), par[0]))
        new_events = really_new_events