diff --git a/events/forms.py b/events/forms.py
index 7ccf600..736abfd 100644
--- a/events/forms.py
+++ b/events/forms.py
@@ -158,6 +158,7 @@ class TeamForm(forms.ModelForm):
fields = [
'name',
'description',
+ 'about_page',
'category',
'city',
'web_url',
@@ -192,7 +193,7 @@ class NewTeamForm(forms.ModelForm):
class TeamDefinitionForm(forms.ModelForm):
class Meta:
model = Team
- fields = ['category', 'web_url', 'description']
+ fields = ['category', 'web_url', 'description', 'about_page']
class DeleteTeamForm(forms.Form):
confirm = forms.BooleanField(label="Yes, delete team", required=True)
diff --git a/events/migrations/0036_auto_20180701_2148.py b/events/migrations/0036_auto_20180701_2148.py
new file mode 100644
index 0000000..62a1499
--- /dev/null
+++ b/events/migrations/0036_auto_20180701_2148.py
@@ -0,0 +1,29 @@
+# Generated by Django 2.0 on 2018-07-01 21:48
+
+from django.db import migrations, models
+import imagekit.models.fields
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('events', '0035_add_event_status'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='team',
+ name='about_page',
+ field=models.TextField(blank=True, null=True),
+ ),
+ migrations.AlterField(
+ model_name='sponsor',
+ name='logo',
+ field=imagekit.models.fields.ProcessedImageField(blank=True, help_text='Will be scaled and cropped to max 250x200 px.', upload_to='sponsors', verbose_name='Logo'),
+ ),
+ migrations.AlterField(
+ model_name='team',
+ name='slug',
+ field=models.CharField(max_length=256, unique=True),
+ ),
+ ]
diff --git a/events/models/profiles.py b/events/models/profiles.py
index ff92fd5..a17dfd5 100644
--- a/events/models/profiles.py
+++ b/events/models/profiles.py
@@ -244,6 +244,8 @@ class Team(models.Model):
description = models.TextField(blank=True, null=True)
+ about_page = models.TextField(blank=True, null=True)
+
country = models.ForeignKey(Country, on_delete=models.CASCADE)
spr = models.ForeignKey(SPR, null=True, blank=True, on_delete=models.CASCADE)
city = models.ForeignKey(City, null=True, blank=True, on_delete=models.CASCADE)
@@ -319,6 +321,9 @@ class Team(models.Model):
self.slug = '%s-%s' % (new_slug, self.id)
super().save(*args, **kwargs) # Call the "real" save() method.
+ def get_absolute_url(self):
+ return reverse('show-team-by-slug', kwargs={'team_slug': self.slug})
+
class Member(models.Model):
NORMAL=0
diff --git a/get_together/templates/get_together/teams/about_team.html b/get_together/templates/get_together/teams/about_team.html
new file mode 100644
index 0000000..79645a9
--- /dev/null
+++ b/get_together/templates/get_together/teams/about_team.html
@@ -0,0 +1,91 @@
+{% extends "get_together/base.html" %}
+{% load static markup tz %}
+
+{% block add_to_title %} | {{team.name}}{% endblock %}
+
+{% block styles %}
+
+{% endblock %}
+
+{% block content %}
+
+
+
+ {% if team.banner_img %}
+
+
+
Welcome to {{ team.name }}
+
+ {% else %}
+
About {{ team.name }}
+ {% endif %}
+
+ {% if can_edit_team %}
+
Edit Team
+
Manage Members
+ {% endif %}
+ {% if is_member %}
+ {% if not team.owner_profile == request.user.profile %}
Leave Team{% endif %}
+ {% else %}
+
Join Team
+ {% endif %}
+
+
+
+
+
+ {{ team.about_page|markdown }}
+
+
+
+
+
+
+
Members
+ {% for member in member_list %}
+
+ {% endfor %}
+
+
+
+
+{% endblock %}
+
diff --git a/get_together/templates/get_together/teams/show_team.html b/get_together/templates/get_together/teams/show_team.html
index 2d62ab9..8b2706e 100644
--- a/get_together/templates/get_together/teams/show_team.html
+++ b/get_together/templates/get_together/teams/show_team.html
@@ -57,6 +57,11 @@
Website: | {{ team.web_url }} |
{% endif %}
+ {% if team.about_page %}
+
+ About: | Learn More about {{ team.name }} |
+
+ {% endif %}
diff --git a/get_together/tests/__init__.py b/get_together/tests/__init__.py
index 8ddcb50..168fc9d 100644
--- a/get_together/tests/__init__.py
+++ b/get_together/tests/__init__.py
@@ -3,3 +3,4 @@ from django.test import TestCase
from .events import *
from .event_reminder import *
from .speakers import *
+from .teams import *
diff --git a/get_together/tests/teams.py b/get_together/tests/teams.py
new file mode 100644
index 0000000..3ae2280
--- /dev/null
+++ b/get_together/tests/teams.py
@@ -0,0 +1,54 @@
+from django.test import TestCase, Client
+from django.shortcuts import resolve_url
+from django.utils import timezone
+from django.urls import reverse
+
+from model_mommy import mommy
+import mock
+import datetime
+
+from django.contrib.auth.models import User
+from events.ipstack import get_ipstack_geocoder
+from events.models import Team
+# Create your tests here.
+
+
+class TeamDisplayTests(TestCase):
+
+ def setUp(self):
+ super().setUp()
+
+ def tearDown(self):
+ super().tearDown()
+
+ def test_show_team(self):
+ team = mommy.make(Team)
+ team.save()
+
+ team_url = team.get_absolute_url()
+
+ c = Client()
+ response = c.get(team_url)
+ assert(response.status_code == 200)
+
+ def test_show_about_team(self):
+ team = mommy.make(Team)
+ team.about_page = "about this team!"
+ team.save()
+
+ team_about_url = reverse('show-team-about-by-slug', kwargs={'team_slug': team.slug})
+
+ c = Client()
+ response = c.get(team_about_url)
+ assert(response.status_code == 200)
+
+ def test_show_about_team_redirects_if_none(self):
+ team = mommy.make(Team)
+ team.about_page = ""
+ team.save()
+
+ team_about_url = reverse('show-team-about-by-slug', kwargs={'team_slug': team.slug})
+
+ c = Client()
+ response = c.get(team_about_url)
+ assert(response.status_code == 302)
diff --git a/get_together/urls.py b/get_together/urls.py
index 9c3f908..a6a26a0 100644
--- a/get_together/urls.py
+++ b/get_together/urls.py
@@ -115,6 +115,7 @@ urlpatterns = [
path('activity_pub/', include('events.activity_pub.urls')),
path('/', views.show_team_by_slug, name='show-team-by-slug'),
+ path('/about/', views.show_team_about_by_slug, name='show-team-about-by-slug'),
]
if settings.DEBUG:
urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
diff --git a/get_together/views/teams.py b/get_together/views/teams.py
index 06262f1..2d080a8 100644
--- a/get_together/views/teams.py
+++ b/get_together/views/teams.py
@@ -49,12 +49,10 @@ def show_team_by_slug(request, team_slug):
team = get_object_or_404(Team, slug=team_slug)
return show_team(request, team)
-
def show_team_by_id(request, team_id):
team = get_object_or_404(Team, id=team_id)
return redirect('show-team-by-slug', team_slug=team.slug)
-
def show_team(request, team):
upcoming_events = Event.objects.filter(team=team, end_time__gt=datetime.datetime.now()).order_by('start_time')
recent_events = Event.objects.filter(team=team, end_time__lte=datetime.datetime.now()).order_by('-start_time')[:5]
@@ -69,6 +67,22 @@ def show_team(request, team):
}
return render(request, 'get_together/teams/show_team.html', context)
+def show_team_about_by_slug(request, team_slug):
+ team = get_object_or_404(Team, slug=team_slug)
+ if team.about_page:
+ return show_team_about(request, team)
+ else:
+ return redirect('show-team-by-slug', team_slug=team.slug)
+
+def show_team_about(request, team):
+ context = {
+ 'team': team,
+ 'is_member': request.user.profile in team.members.all(),
+ 'member_list': Member.objects.filter(team=team).order_by('-role', 'joined_date'),
+ 'can_create_event': request.user.profile.can_create_event(team),
+ 'can_edit_team': request.user.profile.can_edit_team(team),
+ }
+ return render(request, 'get_together/teams/about_team.html', context)
@login_required
def create_team(request, *args, **kwargs):