Example #1
0
 def _create_log_entry(self, action):
     if threadlocals.get_current_user() is None:
         return
         raise Exception("Please enable ThreadsLocal middleware")
     if threadlocals.get_current_user().is_anonymous():
         user = User.objects.get(
             pk=0)  # feature: User with pk=0 supposed to be anonymous user
     else:
         user = threadlocals.get_current_user()
     if SAVE_THROUGH_ADMIN:
         history = LogEntry.objects.get(
             user=user,
             object_id=self.pk,
             action_flag=action,
             content_type=ContentType.objects.get_for_model(self)).latest()
     else:
         history = LogEntry(
             user=user,
             object_id=self.pk,
             action_flag=action,
             content_type=ContentType.objects.get_for_model(self))
         try:
             history.object_repr = repr(self)
         except Exception:
             history.object_repr = "(unknown)"
         history.save()
     return history
Example #2
0
 def _create_field_log_entry(self, name, value, log_entry):
     if threadlocals.get_current_user() is None:
         return
         raise Exception("Please enable ThreadsLocal middleware")
     if threadlocals.get_current_user().is_anonymous():
         user = User.objects.get(pk=0) # feature: User with pk=0 supposed to be anonymous user
     else:
         user = threadlocals.get_current_user()
     from models import AttributeLogEntry
     story = AttributeLogEntry(user=user, object_id = self.pk, field_name=name, log_entry = log_entry,
                         field_value = value, content_type = ContentType.objects.get_for_model(self))
     try:
         story.object_repr = repr(self)
     except Exception:
         story.object_repr = "(unknown)"
     story.save()
Example #3
0
 def _create_log_entry(self, action):
     if threadlocals.get_current_user() is None:
         return
         raise Exception("Please enable ThreadsLocal middleware")
     if threadlocals.get_current_user().is_anonymous():
         user = User.objects.get(pk=0) # feature: User with pk=0 supposed to be anonymous user
     else:
         user = threadlocals.get_current_user()
     if SAVE_THROUGH_ADMIN: 
         history = LogEntry.objects.get(user=user, object_id = self.pk, action_flag = action,
                         content_type = ContentType.objects.get_for_model(self)).latest()
     else:
         history = LogEntry(user=user, object_id = self.pk, action_flag = action,
                             content_type = ContentType.objects.get_for_model(self))
         try:
             history.object_repr = repr(self)
         except Exception:
             history.object_repr = "(unknown)"
         history.save()
     return history
Example #4
0
 def _create_field_log_entry(self, name, value, log_entry):
     if threadlocals.get_current_user() is None:
         return
         raise Exception("Please enable ThreadsLocal middleware")
     if threadlocals.get_current_user().is_anonymous():
         user = User.objects.get(
             pk=0)  # feature: User with pk=0 supposed to be anonymous user
     else:
         user = threadlocals.get_current_user()
     from models import AttributeLogEntry
     story = AttributeLogEntry(
         user=user,
         object_id=self.pk,
         field_name=name,
         log_entry=log_entry,
         field_value=value,
         content_type=ContentType.objects.get_for_model(self))
     try:
         story.object_repr = repr(self)
     except Exception:
         story.object_repr = "(unknown)"
     story.save()