diff --git a/events/admin.py b/events/admin.py index 1e27747..481e81d 100644 --- a/events/admin.py +++ b/events/admin.py @@ -55,11 +55,15 @@ admin.site.register(Organization, OrgAdmin) class TeamAdmin(admin.ModelAdmin): 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',) def member_count(self, team): return team.members.all().count() 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) class SearchableAdmin(admin.ModelAdmin): diff --git a/events/migrations/0029_add_team_premium_fields.py b/events/migrations/0029_add_team_premium_fields.py new file mode 100644 index 0000000..ee955dd --- /dev/null +++ b/events/migrations/0029_add_team_premium_fields.py @@ -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'), + ), + ] diff --git a/events/models/profiles.py b/events/models/profiles.py index 0ab8c4d..836b44c 100644 --- a/events/models/profiles.py +++ b/events/models/profiles.py @@ -224,6 +224,11 @@ class Team(models.Model): category = models.ForeignKey('Category', on_delete=models.SET_NULL, blank=False, null=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 def location_name(self): if self.city: diff --git a/get_together/templates/get_together/events/show_event.html b/get_together/templates/get_together/events/show_event.html index 9385540..5380b49 100644 --- a/get_together/templates/get_together/events/show_event.html +++ b/get_together/templates/get_together/events/show_event.html @@ -147,6 +147,7 @@ {% endif %} + {% if event.team.is_premium %} Presentations: @@ -156,6 +157,7 @@ Propose a talk + {% endif %}
diff --git a/get_together/views/speakers.py b/get_together/views/speakers.py index be4ec74..41dd20e 100644 --- a/get_together/views/speakers.py +++ b/get_together/views/speakers.py @@ -209,6 +209,10 @@ def delete_talk(request, talk_id): @login_required def propose_event_talk(request, 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': profile = request.user.profile talks = list(Talk.objects.filter(speaker__user=profile))