Show More
@@ -145,7 +145,12 b' class BaseModel(object):' | |||||
145 | def delete(cls, id_): |
|
145 | def delete(cls, id_): | |
146 | obj = cls.query().get(id_) |
|
146 | obj = cls.query().get(id_) | |
147 | Session.delete(obj) |
|
147 | Session.delete(obj) | |
148 |
|
148 | |||
|
149 | def __repr__(self): | |||
|
150 | if hasattr(self, '__unicode__'): | |||
|
151 | # python repr needs to return str | |||
|
152 | return safe_str(self.__unicode__()) | |||
|
153 | return '<DB:%s>' % (self.__class__.__name__) | |||
149 |
|
154 | |||
150 | class RhodeCodeSetting(Base, BaseModel): |
|
155 | class RhodeCodeSetting(Base, BaseModel): | |
151 | __tablename__ = 'rhodecode_settings' |
|
156 | __tablename__ = 'rhodecode_settings' | |
@@ -183,8 +188,8 b' class RhodeCodeSetting(Base, BaseModel):' | |||||
183 | """ |
|
188 | """ | |
184 | self._app_settings_value = safe_unicode(val) |
|
189 | self._app_settings_value = safe_unicode(val) | |
185 |
|
190 | |||
186 |
def __ |
|
191 | def __unicode__(self): | |
187 | return "<%s('%s:%s')>" % ( |
|
192 | return u"<%s('%s:%s')>" % ( | |
188 | self.__class__.__name__, |
|
193 | self.__class__.__name__, | |
189 | self.app_settings_name, self.app_settings_value |
|
194 | self.app_settings_name, self.app_settings_value | |
190 | ) |
|
195 | ) | |
@@ -333,8 +338,8 b' class User(Base, BaseModel):' | |||||
333 | def is_admin(self): |
|
338 | def is_admin(self): | |
334 | return self.admin |
|
339 | return self.admin | |
335 |
|
340 | |||
336 |
def __ |
|
341 | def __unicode__(self): | |
337 | return "<%s('id:%s:%s')>" % (self.__class__.__name__, |
|
342 | return u"<%s('id:%s:%s')>" % (self.__class__.__name__, | |
338 | self.user_id, self.username) |
|
343 | self.user_id, self.username) | |
339 |
|
344 | |||
340 | @classmethod |
|
345 | @classmethod | |
@@ -429,8 +434,8 b' class UsersGroup(Base, BaseModel):' | |||||
429 | users_group_to_perm = relationship('UsersGroupToPerm', cascade='all') |
|
434 | users_group_to_perm = relationship('UsersGroupToPerm', cascade='all') | |
430 | users_group_repo_to_perm = relationship('UsersGroupRepoToPerm', cascade='all') |
|
435 | users_group_repo_to_perm = relationship('UsersGroupRepoToPerm', cascade='all') | |
431 |
|
436 | |||
432 |
def __ |
|
437 | def __unicode__(self): | |
433 | return '<userGroup(%s)>' % (self.users_group_name) |
|
438 | return u'<userGroup(%s)>' % (self.users_group_name) | |
434 |
|
439 | |||
435 | @classmethod |
|
440 | @classmethod | |
436 | def get_by_group_name(cls, group_name, cache=False, |
|
441 | def get_by_group_name(cls, group_name, cache=False, | |
@@ -508,9 +513,9 b' class Repository(Base, BaseModel):' | |||||
508 |
|
513 | |||
509 | logs = relationship('UserLog') |
|
514 | logs = relationship('UserLog') | |
510 |
|
515 | |||
511 |
def __ |
|
516 | def __unicode__(self): | |
512 | return "<%s('%s:%s')>" % (self.__class__.__name__, |
|
517 | return u"<%s('%s:%s')>" % (self.__class__.__name__,self.repo_id, | |
513 |
|
|
518 | self.repo_name) | |
514 |
|
519 | |||
515 | @classmethod |
|
520 | @classmethod | |
516 | def url_sep(cls): |
|
521 | def url_sep(cls): | |
@@ -748,8 +753,8 b' class RepoGroup(Base, BaseModel):' | |||||
748 | self.group_name = group_name |
|
753 | self.group_name = group_name | |
749 | self.parent_group = parent_group |
|
754 | self.parent_group = parent_group | |
750 |
|
755 | |||
751 |
def __ |
|
756 | def __unicode__(self): | |
752 | return "<%s('%s:%s')>" % (self.__class__.__name__, self.group_id, |
|
757 | return u"<%s('%s:%s')>" % (self.__class__.__name__, self.group_id, | |
753 | self.group_name) |
|
758 | self.group_name) | |
754 |
|
759 | |||
755 | @classmethod |
|
760 | @classmethod | |
@@ -865,8 +870,8 b' class Permission(Base, BaseModel):' | |||||
865 | permission_name = Column("permission_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
870 | permission_name = Column("permission_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
866 | permission_longname = Column("permission_longname", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
871 | permission_longname = Column("permission_longname", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
867 |
|
872 | |||
868 |
def __ |
|
873 | def __unicode__(self): | |
869 | return "<%s('%s:%s')>" % ( |
|
874 | return u"<%s('%s:%s')>" % ( | |
870 | self.__class__.__name__, self.permission_id, self.permission_name |
|
875 | self.__class__.__name__, self.permission_id, self.permission_name | |
871 | ) |
|
876 | ) | |
872 |
|
877 | |||
@@ -918,8 +923,8 b' class UserRepoToPerm(Base, BaseModel):' | |||||
918 | Session.add(n) |
|
923 | Session.add(n) | |
919 | return n |
|
924 | return n | |
920 |
|
925 | |||
921 |
def __ |
|
926 | def __unicode__(self): | |
922 | return '<user:%s => %s >' % (self.user, self.repository) |
|
927 | return u'<user:%s => %s >' % (self.user, self.repository) | |
923 |
|
928 | |||
924 |
|
929 | |||
925 | class UserToPerm(Base, BaseModel): |
|
930 | class UserToPerm(Base, BaseModel): | |
@@ -962,8 +967,8 b' class UsersGroupRepoToPerm(Base, BaseMod' | |||||
962 | Session.add(n) |
|
967 | Session.add(n) | |
963 | return n |
|
968 | return n | |
964 |
|
969 | |||
965 |
def __ |
|
970 | def __unicode__(self): | |
966 | return '<userGroup:%s => %s >' % (self.users_group, self.repository) |
|
971 | return u'<userGroup:%s => %s >' % (self.users_group, self.repository) | |
967 |
|
972 | |||
968 |
|
973 | |||
969 | class UsersGroupToPerm(Base, BaseModel): |
|
974 | class UsersGroupToPerm(Base, BaseModel): | |
@@ -1076,8 +1081,8 b' class CacheInvalidation(Base, BaseModel)' | |||||
1076 | self.cache_args = cache_args |
|
1081 | self.cache_args = cache_args | |
1077 | self.cache_active = False |
|
1082 | self.cache_active = False | |
1078 |
|
1083 | |||
1079 |
def __ |
|
1084 | def __unicode__(self): | |
1080 | return "<%s('%s:%s')>" % (self.__class__.__name__, |
|
1085 | return u"<%s('%s:%s')>" % (self.__class__.__name__, | |
1081 | self.cache_id, self.cache_key) |
|
1086 | self.cache_id, self.cache_key) | |
1082 | @classmethod |
|
1087 | @classmethod | |
1083 | def clear_cache(cls): |
|
1088 | def clear_cache(cls): |
@@ -112,6 +112,7 b' class NotificationModel(BaseModel):' | |||||
112 | kwargs.update(email_kwargs) |
|
112 | kwargs.update(email_kwargs) | |
113 | email_body_html = EmailNotificationModel()\ |
|
113 | email_body_html = EmailNotificationModel()\ | |
114 | .get_email_tmpl(type_, **kwargs) |
|
114 | .get_email_tmpl(type_, **kwargs) | |
|
115 | ||||
115 | run_task(tasks.send_email, rec.email, email_subject, email_body, |
|
116 | run_task(tasks.send_email, rec.email, email_subject, email_body, | |
116 | email_body_html) |
|
117 | email_body_html) | |
117 |
|
118 | |||
@@ -183,6 +184,7 b' class NotificationModel(BaseModel):' | |||||
183 | else: |
|
184 | else: | |
184 | DTF = lambda d: datetime.datetime.strftime(d, DATETIME_FORMAT) |
|
185 | DTF = lambda d: datetime.datetime.strftime(d, DATETIME_FORMAT) | |
185 | when = DTF(notification.created_on) |
|
186 | when = DTF(notification.created_on) | |
|
187 | ||||
186 | data = dict( |
|
188 | data = dict( | |
187 | user=notification.created_by_user.username, |
|
189 | user=notification.created_by_user.username, | |
188 | action=_map[notification.type_], when=when, |
|
190 | action=_map[notification.type_], when=when, |
General Comments 0
You need to be logged in to leave comments.
Login now