how to acheive this

2024-05-09 Thread malhaar mahapatro
I have scrpaded and saved attachment I want to send it to dashboard  of
iso,isto and irt and I want an option that they have seen that message or
not and what action taken I can see and then can send again to csirt
dashboard about action taken and csirt can send it to whom he wants how to
achieve in django from scratch using django

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMgb%2BbF1F39ESJFYpKHgai5ugWK2A6c%3Dp-Bat52bNHYbJJV3%2BQ%40mail.gmail.com.


How to acheive search auditlog through Django auditlog package

2019-03-05 Thread desousa01071997
In django auditlog Create,Update and Delete is working fine for me.For 
search I try to customize the given default package. In that package they 
are mentioned The valid actions are :py:attr:`Action.CREATE`, 
:py:attr:`Action.UPDATE` and :py:attr:`Action.DELETE`.though I have tried 
but I am unable to achieve the goal. Here I have mentioned code below

*Models.py:*

@python_2_unicode_compatible
class LogEntry(models.Model):
"""
Represents an entry in the audit log. The content type is saved along 
with the textual and numeric (if available)
primary key, as well as the textual representation of the object when 
it was saved. It holds the action performed
and the fields that were changed in the transaction.

If AuditlogMiddleware is used, the actor will be set automatically. 
Keep in mind that editing / re-saving LogEntry
instances may set the actor to a wrong value - editing LogEntry 
instances is not recommended (and it should not be
necessary).
"""

class Action:
"""
The actions that Auditlog distinguishes: creating, updating and 
deleting objects. Viewing objects is not logged.
The values of the actions are numeric, a higher integer value means 
a more intrusive action. This may be useful
in some cases when comparing actions because the ``__lt``, 
``__lte``, ``__gt``, ``__gte`` lookup filters can be
used in queries.

The valid actions are :py:attr:`Action.CREATE`, 
:py:attr:`Action.UPDATE` and :py:attr:`Action.DELETE`.
"""
CREATE = 0
UPDATE = 1
DELETE = 2

choices = (
(CREATE, _("create")),
(UPDATE, _("update")),
(DELETE, _("delete")),
)

content_type = models.ForeignKey(to='contenttypes.ContentType', 
on_delete=models.CASCADE, related_name='+', verbose_name=_("content type"))
object_pk = models.CharField(db_index=True, max_length=255, 
verbose_name=_("object pk"))
object_id = models.BigIntegerField(blank=True, db_index=True, 
null=True, verbose_name=_("object id"))
object_repr = models.TextField(verbose_name=_("object representation"))
action = models.PositiveSmallIntegerField(choices=Action.choices, 
verbose_name=_("action"))
changes = models.TextField(blank=True, verbose_name=_("change message"))
actor = models.ForeignKey(to=settings.AUTH_USER_MODEL, 
on_delete=models.SET_NULL, blank=True, null=True, related_name='+', 
verbose_name=_("actor"))
# remote_addr = models.GenericIPAddressField(blank=True, null=True, 
verbose_name=_("remote address"))
timestamp = models.DateTimeField(auto_now_add=True, 
verbose_name=_("timestamp"))
# additional_data = JSONField(blank=True, null=True, 
verbose_name=_("additional data"))

objects = LogEntryManager()

class Meta:
get_latest_by = 'timestamp'
ordering = ['-timestamp']
verbose_name = _("log entry")
verbose_name_plural = _("log entries")

def __str__(self):
if self.action == self.Action.CREATE:
fstring = _("Created {repr:s}")
elif self.action == self.Action.UPDATE:
print("updating",self.action)
fstring = _("Updated {repr:s}")
print(fstring)
elif self.action == self.Action.DELETE:
fstring = _("Deleted {repr:s}")
else:
fstring = _("Logged {repr:s}")

return fstring.format(repr=self.object_repr)

@property
def changes_dict(self):
"""
:return: The changes recorded in this log entry as a dictionary 
object.
"""
try:
return json.loads(self.changes)
except ValueError:
return {}

@property
def changes_str(self, colon=': ', arrow=smart_text(' \u2192 '), 
separator='; '):
"""
Return the changes recorded in this log entry as a string. The 
formatting of the string can be customized by
setting alternate values for colon, arrow and separator. If the 
formatting is still not satisfying, please use
:py:func:`LogEntry.changes_dict` and format the string yourself.

:param colon: The string to place between the field name and the 
values.
:param arrow: The string to place between each old and new value.
:param separator: The string to place between each field.
:return: A readable string of the changes in this log entry.
"""
substrings = []

for field, values in iteritems(self.changes_dict):
substring = 
smart_text('{field_name:s}{colon:s}{old:s}{arrow:s}{new:s}').format(
field_name=field,
colon=colon,
old=values[0],
arrow=arrow,
new=values[1],
)
substrings.append(substring)

return separator.join(substrings)

@property
def changes_display_dict(self):
"""
:return: The changes recorded in this log entry