Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #131 - featured team on userprofile #139

Merged
merged 4 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions profiles/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ class Meta:
'favorite_game',
'favorite_console',
'country',
'email_enabled'
'email_enabled',
'feat_team'
)

def __init__(self, *args, **kwargs):
super(EditProfileForm, self).__init__(*args, **kwargs)
self.fields['email_enabled'].widget.attrs.update({'name': 'email_enabled', 'class': 'form-control',
'style': 'background-color: black;'})
self.fields['feat_team'].queryset = self.instance.founder_teams.all() | self.instance.captain_teams.all() | self.instance.player_teams.all()
# super(EditProfileForm, self).__init__(*args, **kwargs)
mikemaddem marked this conversation as resolved.
Show resolved Hide resolved
# self.fields['email_enabled'].widget.attrs.update({'name': 'email_enabled', 'class': 'form-control',
# 'style': 'background-color: black;'})


class SortForm(forms.Form): # it works but is messy af. should be replaced with something like
Expand Down
20 changes: 20 additions & 0 deletions profiles/migrations/0006_userprofile_feat_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 2.2.12 on 2021-04-29 22:39

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('teams', '0003_team_tag'),
('profiles', '0005_auto_20210202_1702'),
]

operations = [
migrations.AddField(
model_name='userprofile',
name='feat_team',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='profile_feat_team', to='teams.Team'),
),
]
19 changes: 19 additions & 0 deletions profiles/migrations/0007_auto_20210429_1901.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.12 on 2021-04-29 23:01

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('profiles', '0006_userprofile_feat_team'),
]

operations = [
migrations.AlterField(
model_name='userprofile',
name='feat_team',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='profile_feat_team', to='teams.Team'),
),
]
2 changes: 2 additions & 0 deletions profiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def __str__(self):
country = CountryField(blank_label='(select country)', default='US')

email_enabled = models.BooleanField(default=True)
# team to display on their profile
feat_team = models.ForeignKey('teams.Team', related_name='profile_feat_team', blank=True, null=True, on_delete=models.SET_NULL)
mikemaddem marked this conversation as resolved.
Show resolved Hide resolved
# teams the user founded
founder_teams = models.ManyToManyField('teams.Team', related_name='profile_founder_teams', blank=True)
# teams the user is a captain of
Expand Down
3 changes: 3 additions & 0 deletions project-templates/profiles/edit_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<label>Alternate Name</label>
<div class="form-group">{{ form.alternate_name }}</div>

<label>Featured Team</label>
<div class="form-group">{{ form.feat_team }}</div>

<label>Xbox Live</label>
<div class="form-group">{{ form.xbl }}</div>

Expand Down