Esempio n. 1
0
 def _create_log_entry(self, action):
     if not threadlocals.get_current_user() or threadlocals.get_current_user().is_anonymous():
         user = User.objects.get(username="******")
     else:
         user = threadlocals.get_current_user()
     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()
Esempio n. 2
0
	def get_available_states(self, object):
		""" возвращает список доступных переходов """
		from rights import has_access
		q = StateTransform.objects.filter(from_state=self)
		if not has_access(get_current_user(),'reviewing'):
			q = [x for x in q if not x.to_state.name in [u'опубликованный', u'на главной']]
		return [{'url': x.slug, 'name':x.to_state.name} for x in q]
Esempio n. 3
0
 def get_db_prep_save(self, value):
     user = threadlocals.get_current_user()
     if user != None and self.editable == True or value == None:
         return user.id
     elif value != None:
         return value
     else:
         return None
Esempio n. 4
0
    def _create_field_log_entry(self, name, value):
        if not threadlocals.get_current_user() or threadlocals.get_current_user().is_anonymous():
            user = User.objects.get(username="******")
        else:
            user = threadlocals.get_current_user()
        from core.models import AttributeLogEntry

        history = AttributeLogEntry(
            user=user,
            object_id=self.pk,
            field_name=name,
            field_value=value,
            content_type=ContentType.objects.get_for_model(self),
        )
        try:
            history.object_repr = repr(self)
        except Exception:
            history.object_repr = "(unknown)"
        history.save()
Esempio n. 5
0
 def get_available_states(self, object):
     """ возвращает список доступных переходов """
     from rights import has_access
     q = StateTransform.objects.filter(from_state=self)
     if not has_access(get_current_user(), 'reviewing'):
         q = [
             x for x in q
             if not x.to_state.name in [u'опубликованный', u'на главной']
         ]
     return [{'url': x.slug, 'name': x.to_state.name} for x in q]