Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion admin/templates/brands/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ <h2>List of Brands</h2>
<thead>
<tr>
<th>Name</th>
<th>Service</th>
</tr>
</thead>
<tbody>
{% for brand in brands %}
{% for brand in brands|dictsort:"name" %}
<tr>
<td><a href="{% url 'brands:detail' brand_id=brand.id %}">{{ brand.name }}</a></td>
<td>{{ brand.get_provider_types }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
13 changes: 13 additions & 0 deletions osf/models/brand.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,18 @@ class Meta:
secondary_color = models.CharField(max_length=7)
background_color = models.CharField(max_length=7, blank=True, null=True)

def get_provider_types(self):
unique_types = self.providers.values_list('type', flat=True).distinct()
results = []
# cast osf.collectionprovider, osf.registrationprovider, osf.preprintprovider to more readable UI format
for unique_type in unique_types:
if 'registration' in unique_type:
results.append('Registry')
elif 'collection' in unique_type:
results.append('Collection')
elif 'preprint' in unique_type:
results.append('Preprint')
return ', '.join(results)

def __str__(self):
return f'{self.name} ({self.id})'
Loading