Beispiel #1
0
    def save_edit(
        self,
        user={},
        note="",
        edit_type="",
        old_value=None,
        new_value=None,
        newprovisionalvalue=None,
        oldprovisionalvalue=None,
        provisional_edit_log_details=None,
        transaction_id=None,
        new_resource_created=False,
    ):
        if new_resource_created:
            timestamp = datetime.datetime.now()
            resource_edit = EditLog()
            resource_edit.resourceclassid = self.resourceinstance.graph_id
            resource_edit.resourceinstanceid = self.resourceinstance.resourceinstanceid
            resource_edit.edittype = "create"
            resource_edit.timestamp = timestamp
            resource_edit.userid = getattr(user, "id", "")
            resource_edit.user_email = getattr(user, "email", "")
            resource_edit.user_firstname = getattr(user, "first_name", "")
            resource_edit.user_lastname = getattr(user, "last_name", "")
            resource_edit.user_username = getattr(user, "username", "")
            if transaction_id is not None:
                resource_edit.transactionid = transaction_id
            resource_edit.save()

        timestamp = datetime.datetime.now()
        edit = EditLog()
        edit.resourceclassid = self.resourceinstance.graph_id
        edit.resourceinstanceid = self.resourceinstance.resourceinstanceid
        edit.nodegroupid = self.nodegroup_id
        edit.tileinstanceid = self.tileid
        if provisional_edit_log_details is not None:
            edit.provisional_user_username = getattr(
                provisional_edit_log_details["provisional_editor"], "username",
                "")
            edit.provisional_userid = getattr(
                provisional_edit_log_details["provisional_editor"], "id", "")
            edit.provisional_edittype = provisional_edit_log_details["action"]
            user = provisional_edit_log_details["user"]
        edit.userid = getattr(user, "id", "")
        edit.user_email = getattr(user, "email", "")
        edit.user_firstname = getattr(user, "first_name", "")
        edit.user_lastname = getattr(user, "last_name", "")
        edit.user_username = getattr(user, "username", "")
        edit.resourcedisplayname = Resource.objects.get(
            resourceinstanceid=self.resourceinstance.resourceinstanceid
        ).displayname
        edit.oldvalue = old_value
        edit.newvalue = new_value
        edit.timestamp = timestamp
        edit.edittype = edit_type
        edit.newprovisionalvalue = newprovisionalvalue
        edit.oldprovisionalvalue = oldprovisionalvalue
        if transaction_id is not None:
            edit.transactionid = transaction_id
        edit.save()
Beispiel #2
0
 def save_edit(self,
               user={},
               note='',
               edit_type='',
               old_value=None,
               new_value=None,
               newprovisionalvalue=None,
               oldprovisionalvalue=None):
     timestamp = datetime.datetime.now()
     edit = EditLog()
     edit.resourceclassid = self.resourceinstance.graph_id
     edit.resourceinstanceid = self.resourceinstance.resourceinstanceid
     edit.nodegroupid = self.nodegroup_id
     edit.tileinstanceid = self.tileid
     edit.userid = getattr(user, 'id', '')
     edit.user_email = getattr(user, 'email', '')
     edit.user_firstname = getattr(user, 'first_name', '')
     edit.user_lastname = getattr(user, 'last_name', '')
     edit.user_username = getattr(user, 'username', '')
     edit.resourcedisplayname = Resource.objects.get(
         resourceinstanceid=self.resourceinstance.resourceinstanceid
     ).displayname
     edit.oldvalue = old_value
     edit.newvalue = new_value
     edit.timestamp = timestamp
     edit.edittype = edit_type
     edit.newprovisionalvalue = newprovisionalvalue
     edit.oldprovisionalvalue = oldprovisionalvalue
     edit.save()
Beispiel #3
0
 def save_edit(self, user={}, note='', edit_type='', old_value=None, new_value=None):
     timestamp = datetime.datetime.now()
     edit = EditLog()
     edit.resourceclassid = self.resourceinstance.graph_id
     edit.resourceinstanceid = self.resourceinstance.resourceinstanceid
     edit.nodegroupid = self.nodegroup_id
     edit.tileinstanceid = self.tileid
     edit.userid = getattr(user, 'id', '')
     edit.user_email = getattr(user, 'email', '')
     edit.user_firstname = getattr(user, 'first_name', '')
     edit.user_lastname = getattr(user, 'last_name', '')
     edit.note = note
     edit.oldvalue = old_value
     edit.newvalue = new_value
     edit.timestamp = timestamp
     edit.edittype = edit_type
     edit.save()