diff --git a/dribdat/apipackage.py b/dribdat/apipackage.py
index 2999a2e2..dacb8a15 100644
--- a/dribdat/apipackage.py
+++ b/dribdat/apipackage.py
@@ -29,7 +29,7 @@ def event_to_data_package(event, author=None, host_url='', full_content=False):
contributors = []
if author and not author.is_anonymous and author.is_admin:
contributors.append({
- "title": author.username,
+ "title": author.name,
"path": author.webpage_url or '',
"role": "author"
})
diff --git a/dribdat/mailer.py b/dribdat/mailer.py
index 91882d71..166068e3 100644
--- a/dribdat/mailer.py
+++ b/dribdat/mailer.py
@@ -17,7 +17,7 @@ def user_activation_message(user, act_hash):
msg = EmailMessage(from_email=from_email)
msg.subject = 'Your dribdat account'
msg.body = \
- "Hello %s,\n" % user.username \
+ "Hello %s,\n" % user.name \
+ "Thanks for signing up at %s\n\n" % base_url \
+ "Tap here to activate your account:\n\n%s" % act_url
logging.debug(act_url)
diff --git a/dribdat/templates/admin/projects.html b/dribdat/templates/admin/projects.html
index 806f7442..ae63696e 100644
--- a/dribdat/templates/admin/projects.html
+++ b/dribdat/templates/admin/projects.html
@@ -65,7 +65,7 @@
{{ project.category.name }} |
{{ project.created_at|format_date }}
- {{ project.user.username }} |
+
{{ project.user.name }}
{{ project.updated_at|since_date }} |
{% if s.ref_url %}
diff --git a/dribdat/templates/public/eventprint.html b/dribdat/templates/public/eventprint.html
index 89823b93..f378c19d 100644
--- a/dribdat/templates/public/eventprint.html
+++ b/dribdat/templates/public/eventprint.html
@@ -43,7 +43,7 @@
Updated: {{ project.updated_at|format_date }} ({{project.score}}% complete)
Created: {{ project.created_at|format_date }}
{% if project.user %}
- by {{ project.user.username }}
+ by {{ project.user.name }}
{% endif %}
{% if project.category_id %}
Category: {{ project.category.name }}
@@ -108,7 +108,7 @@
Updated: {{ project.updated_at|format_date }}
Created: {{ project.created_at|format_date }}
{% if project.user %}
- by {{ project.user.username }}
+ by {{ project.user.name }}
{% endif %}
{% if project.category_id %}
Category: {{ project.category.name }}
diff --git a/dribdat/user/models.py b/dribdat/user/models.py
index bb1c57a2..ece594cc 100644
--- a/dribdat/user/models.py
+++ b/dribdat/user/models.py
@@ -116,11 +116,13 @@ class User(UserMixin, PkModel):
"""Get JSON representation."""
return {
'id': self.id,
+ 'name': self.name,
'email': self.email,
'sso_id': self.sso_id,
'active': self.active,
'is_admin': self.is_admin,
'username': self.username,
+ 'fullname': self.fullname,
'webpage_url': self.webpage_url,
'roles': ",".join([r.name for r in self.roles]),
'cardtype': self.cardtype,
@@ -208,19 +210,24 @@ class User(UserMixin, PkModel):
).order_by(Project.id.desc()).all()
return projects
- def latest_posts(self, max=None):
+ def latest_posts(self, max=None, only_posts=True):
"""Retrieve the latest content from the user."""
- activities = Activity.query.filter_by(
- user_id=self.id, action='post'
- ).order_by(Activity.timestamp.desc())
+ activities = Activity.query.filter_by(user_id=self.id)
+ if only_posts:
+ activities = activities.filter_by(action='post')
+ activities = activities.order_by(Activity.timestamp.desc())
if max is not None:
activities = activities.limit(max)
posts = []
for a in activities.all():
- if not a.project.is_hidden:
+ if a.project and not a.project.is_hidden:
posts.append(a.data)
return posts
+ @property
+ def name(self):
+ return self.fullname or self.username
+
@property
def last_active(self):
"""Retrieve last user activity."""
diff --git a/tests/factories.py b/tests/factories.py
index 967f8554..297a590e 100644
--- a/tests/factories.py
+++ b/tests/factories.py
@@ -13,7 +13,6 @@ class BaseFactory(SQLAlchemyModelFactory):
class Meta:
"""Factory configuration."""
-
abstract = True
sqlalchemy_session = db.session
|