Add premium fields to Team objects, only show presentations for premium teams
This commit is contained in:
parent
8e7c955928
commit
f5ac0c2fdd
5 changed files with 65 additions and 1 deletions
|
@ -55,11 +55,15 @@ admin.site.register(Organization, OrgAdmin)
|
||||||
|
|
||||||
class TeamAdmin(admin.ModelAdmin):
|
class TeamAdmin(admin.ModelAdmin):
|
||||||
raw_id_fields = ('country', 'spr', 'city', 'owner_profile', 'admin_profiles', 'contact_profiles')
|
raw_id_fields = ('country', 'spr', 'city', 'owner_profile', 'admin_profiles', 'contact_profiles')
|
||||||
list_display = ('__str__', 'member_count', 'owner_profile', 'created_date')
|
list_display = ('__str__', 'active', 'member_count', 'event_count', 'owner_profile', 'created_date', 'is_premium', 'premium_expires')
|
||||||
|
list_filter = ('active', 'is_premium', 'organization', 'country',)
|
||||||
ordering = ('-created_date',)
|
ordering = ('-created_date',)
|
||||||
def member_count(self, team):
|
def member_count(self, team):
|
||||||
return team.members.all().count()
|
return team.members.all().count()
|
||||||
member_count.short_description = 'Members'
|
member_count.short_description = 'Members'
|
||||||
|
def event_count(self, team):
|
||||||
|
return team.event_set.all().count()
|
||||||
|
event_count.short_description = 'Events'
|
||||||
admin.site.register(Team, TeamAdmin)
|
admin.site.register(Team, TeamAdmin)
|
||||||
|
|
||||||
class SearchableAdmin(admin.ModelAdmin):
|
class SearchableAdmin(admin.ModelAdmin):
|
||||||
|
|
49
events/migrations/0029_add_team_premium_fields.py
Normal file
49
events/migrations/0029_add_team_premium_fields.py
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
# Generated by Django 2.0 on 2018-04-27 21:59
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('events', '0028_add_speaker_models'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='team',
|
||||||
|
name='is_premium',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='team',
|
||||||
|
name='premium_by',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='premium_teams', to='events.UserProfile'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='team',
|
||||||
|
name='premium_expires',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='team',
|
||||||
|
name='premium_started',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='presentation',
|
||||||
|
name='talk',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='presentations', to='events.Talk'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='speaker',
|
||||||
|
name='bio',
|
||||||
|
field=models.TextField(blank=True, verbose_name='Biography'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='talk',
|
||||||
|
name='speaker',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='talks', to='events.Speaker', verbose_name='Speaker Bio'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -224,6 +224,11 @@ class Team(models.Model):
|
||||||
category = models.ForeignKey('Category', on_delete=models.SET_NULL, blank=False, null=True)
|
category = models.ForeignKey('Category', on_delete=models.SET_NULL, blank=False, null=True)
|
||||||
topics = models.ManyToManyField('Topic', blank=True)
|
topics = models.ManyToManyField('Topic', blank=True)
|
||||||
|
|
||||||
|
is_premium = models.BooleanField(default=False)
|
||||||
|
premium_by = models.ForeignKey(UserProfile, related_name='premium_teams', null=True, on_delete=models.SET_NULL)
|
||||||
|
premium_started = models.DateTimeField(blank=True, null=True)
|
||||||
|
premium_expires = models.DateTimeField(blank=True, null=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def location_name(self):
|
def location_name(self):
|
||||||
if self.city:
|
if self.city:
|
||||||
|
|
|
@ -147,6 +147,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if event.team.is_premium %}
|
||||||
<tr>
|
<tr>
|
||||||
<td width="120px"><b>Presentations:</b></td>
|
<td width="120px"><b>Presentations:</b></td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -156,6 +157,7 @@
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'propose-event-talk' event.id %}">Propose a talk</a>
|
<a class="btn btn-primary btn-sm" href="{% url 'propose-event-talk' event.id %}">Propose a talk</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="container mt-3">
|
<div class="container mt-3">
|
||||||
|
|
|
@ -209,6 +209,10 @@ def delete_talk(request, talk_id):
|
||||||
@login_required
|
@login_required
|
||||||
def propose_event_talk(request, event_id):
|
def propose_event_talk(request, event_id):
|
||||||
event = get_object_or_404(Event, id=event_id)
|
event = get_object_or_404(Event, id=event_id)
|
||||||
|
if not event.team.is_premium:
|
||||||
|
messages.add_message(request, messages.ERROR, message=_("You can not propose a talk to this team's events."))
|
||||||
|
return redirect(event.get_absolute_url())
|
||||||
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
profile = request.user.profile
|
profile = request.user.profile
|
||||||
talks = list(Talk.objects.filter(speaker__user=profile))
|
talks = list(Talk.objects.filter(speaker__user=profile))
|
||||||
|
|
Loading…
Reference in a new issue