mirror of https://codeberg.org/dribdat/dribdat.git
User.name and fullname instead of username
This commit is contained in:
parent
911d936b02
commit
b1207e2cc7
|
@ -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"
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
</td>
|
||||
<td>{{ project.category.name }}</td>
|
||||
<td>{{ project.created_at|format_date }}
|
||||
<small><br>{{ project.user.username }}</small></td>
|
||||
<small><br>{{ project.user.name }}</small></td>
|
||||
<td>{{ project.updated_at|since_date }}</td>
|
||||
<td><div class="btn-group">
|
||||
<a href="{{ url_for('admin.project_view', project_id=project.id) }}" class="btn btn-warning">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{% if user.carddata %}
|
||||
<img src="{{user.carddata}}"/>
|
||||
{% endif %}
|
||||
<span>{{ user.username }}</span>
|
||||
<span>{{ user.name }}</span>
|
||||
<div class="team-roles">
|
||||
{% for role in user.roles %}
|
||||
{% if role.name %}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
Or contact one of the organisers on this site:</p>
|
||||
<p class="organisers font-weight-bold">
|
||||
{% for user in orgs %}
|
||||
🕴️<a href="{{ url_for('public.user', username=user.username) }}">{{ user.username }}</a>
|
||||
🕴️<a href="{{ url_for('public.user', username=user.username) }}">{{ user.name }}</a>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div><!-- /organiser -->
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
~
|
||||
<a class="userlink"
|
||||
href="{{ url_for('public.user', username=s.user.username )}}">
|
||||
{{ s.user.username }}</a>
|
||||
{{ s.user.name }}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if s.ref_url %}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<li>Updated: <span>{{ project.updated_at|format_date }}</span> ({{project.score}}% complete)</li>
|
||||
<li>Created: <span>{{ project.created_at|format_date }}</span>
|
||||
{% if project.user %}
|
||||
by <a href="{{project.user.webpage_url}}">{{ project.user.username }}</a>
|
||||
by <a href="{{project.user.webpage_url}}">{{ project.user.name }}</a>
|
||||
{% endif %}</li>
|
||||
{% if project.category_id %}
|
||||
<li>Category: <b>{{ project.category.name }}</b></li>
|
||||
|
@ -108,7 +108,7 @@
|
|||
<li>Updated: <span>{{ project.updated_at|format_date }}</span></li>
|
||||
<li>Created: <span>{{ project.created_at|format_date }}</span>
|
||||
{% if project.user %}
|
||||
by <a href="{{project.user.webpage_url}}">{{ project.user.username }}</a>
|
||||
by <a href="{{project.user.webpage_url}}">{{ project.user.name }}</a>
|
||||
{% endif %}</li>
|
||||
{% if project.category_id %}
|
||||
<li>Category: <b>{{ project.category.name }}</b></li>
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -13,7 +13,6 @@ class BaseFactory(SQLAlchemyModelFactory):
|
|||
|
||||
class Meta:
|
||||
"""Factory configuration."""
|
||||
|
||||
abstract = True
|
||||
sqlalchemy_session = db.session
|
||||
|
||||
|
|
Loading…
Reference in New Issue