Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 6, 2024
1 parent c518b9e commit 90103f1
Show file tree
Hide file tree
Showing 16 changed files with 301 additions and 155 deletions.
5 changes: 3 additions & 2 deletions corpus/impulse/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django.contrib import admin
from impulse.models import Announcement
from impulse.models import ImpulseUser
from impulse.models import Team
from impulse.models import Invite
from impulse.models import Team

# Register your models here.

admin.site.register(ImpulseUser)
admin.site.register(Team)
admin.site.register(Announcement)
admin.site.register(Invite)
admin.site.register(Invite)
4 changes: 2 additions & 2 deletions corpus/impulse/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class ImpulseConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'impulse'
default_auto_field = "django.db.models.BigAutoField"
name = "impulse"
27 changes: 21 additions & 6 deletions corpus/impulse/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from impulse.models import ImpulseUser, Team, Announcement, Invite
from django import forms
from impulse.models import Announcement
from impulse.models import ImpulseUser
from impulse.models import Invite
from impulse.models import Team

from corpus.forms import CorpusModelForm


class ImpulseForm(CorpusModelForm):
class Meta:
model = ImpulseUser
Expand All @@ -19,19 +24,21 @@ def clean(self):
raise forms.ValidationError(
"Enter your roll number for verification that you are from NITK"
)

if data.get("ieee_member", None) and not data.get("ieee_membership_no", None):
raise forms.ValidationError(
"Enter your IEEE Membership Number for verification that you are an IEEE member"
)

return data


class TeamCreationForm(CorpusModelForm):
class Meta:
model = Team
fields = ["team_name"]


class AnnouncementForm(CorpusModelForm):

ANNOUNCEMENT_OPTIONS = [
Expand All @@ -43,11 +50,19 @@ class AnnouncementForm(CorpusModelForm):
announcement_mailing = forms.ChoiceField(
widget=forms.Select, choices=ANNOUNCEMENT_OPTIONS
)

class Meta:
model = Announcement
fields = ["content", "url_link", "url_link_text", "announcement_type", "announcement_mailing"]

fields = [
"content",
"url_link",
"url_link_text",
"announcement_type",
"announcement_mailing",
]


class InviteForm(CorpusModelForm):
class Meta:
model = Invite
fields = ["invite_email"]
fields = ["invite_email"]
161 changes: 126 additions & 35 deletions corpus/impulse/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by Django 4.2.7 on 2024-01-02 13:37

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


class Migration(migrations.Migration):
Expand All @@ -15,54 +15,145 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name='Announcement',
name="Announcement",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('content', models.TextField()),
('url_link', models.URLField(blank=True, null=True)),
('url_link_text', models.CharField(blank=True, max_length=200, null=True)),
('announcement_type', models.CharField(choices=[('A', 'All'), ('P', 'Paid Teams'), ('U', 'Unpaid Teams'), ('N', 'Not Registered Teams')], default='A', max_length=1)),
('date_created', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("content", models.TextField()),
("url_link", models.URLField(blank=True, null=True)),
(
"url_link_text",
models.CharField(blank=True, max_length=200, null=True),
),
(
"announcement_type",
models.CharField(
choices=[
("A", "All"),
("P", "Paid Teams"),
("U", "Unpaid Teams"),
("N", "Not Registered Teams"),
],
default="A",
max_length=1,
),
),
("date_created", models.DateTimeField(auto_now_add=True)),
("date_modified", models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name='ImpulseUser',
name="ImpulseUser",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('from_nitk', models.BooleanField(default=True)),
('college_name', models.CharField(default='National Institute of Technology Karnataka', max_length=200)),
('roll_no', models.CharField(blank=True, max_length=8, null=True)),
('ieee_member', models.BooleanField(default=False)),
('ieee_membership_no', models.BigIntegerField(blank=True, null=True)),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("from_nitk", models.BooleanField(default=True)),
(
"college_name",
models.CharField(
default="National Institute of Technology Karnataka",
max_length=200,
),
),
("roll_no", models.CharField(blank=True, max_length=8, null=True)),
("ieee_member", models.BooleanField(default=False)),
("ieee_membership_no", models.BigIntegerField(blank=True, null=True)),
],
),
migrations.CreateModel(
name='Team',
name="Team",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('team_name', models.CharField(max_length=200)),
('payment_status', models.CharField(choices=[('E', 'Exempt'), ('U', 'Fee Not Paid'), ('P', 'Fee Paid')], default='U', max_length=1)),
('payment_proof', models.ImageField(blank=True, null=True, upload_to='img/impulse/payment_proofs')),
('team_leader', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='leader', to='impulse.impulseuser')),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("team_name", models.CharField(max_length=200)),
(
"payment_status",
models.CharField(
choices=[
("E", "Exempt"),
("U", "Fee Not Paid"),
("P", "Fee Paid"),
],
default="U",
max_length=1,
),
),
(
"payment_proof",
models.ImageField(
blank=True, null=True, upload_to="img/impulse/payment_proofs"
),
),
(
"team_leader",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="leader",
to="impulse.impulseuser",
),
),
],
),
migrations.CreateModel(
name='Invite',
name="Invite",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('invite_email', models.EmailField(max_length=254)),
('inviting_team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invite_to_team', to='impulse.team')),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("invite_email", models.EmailField(max_length=254)),
(
"inviting_team",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="invite_to_team",
to="impulse.team",
),
),
],
),
migrations.AddField(
model_name='impulseuser',
name='team',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='team', to='impulse.team'),
model_name="impulseuser",
name="team",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="team",
to="impulse.team",
),
),
migrations.AddField(
model_name='impulseuser',
name='user',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
model_name="impulseuser",
name="user",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
]
]
7 changes: 3 additions & 4 deletions corpus/impulse/migrations/0002_remove_team_payment_proof.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Generated by Django 4.2.7 on 2024-01-03 06:06

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('impulse', '0001_initial'),
("impulse", "0001_initial"),
]

operations = [
migrations.RemoveField(
model_name='team',
name='payment_proof',
model_name="team",
name="payment_proof",
),
]
16 changes: 11 additions & 5 deletions corpus/impulse/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from accounts.models import User
from django.db import models
from embedathon.models import PAYMENT_STATUS
from accounts.models import User


class ImpulseUser(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Expand All @@ -17,7 +18,8 @@ class ImpulseUser(models.Model):

def __str__(self):
return self.user.email



class Team(models.Model):
team_name = models.CharField(max_length=200, blank=False, null=False)
team_leader = models.ForeignKey(
Expand All @@ -30,7 +32,8 @@ class Team(models.Model):

def __str__(self):
return self.team_name



class Announcement(models.Model):

AnnouncementType = (
Expand All @@ -43,18 +46,21 @@ class Announcement(models.Model):
content = models.TextField(blank=False, null=False)
url_link = models.URLField(blank=True, null=True)
url_link_text = models.CharField(max_length=200, blank=True, null=True)
announcement_type = models.CharField(max_length=1, choices=AnnouncementType, blank=False, null=False, default="A")
announcement_type = models.CharField(
max_length=1, choices=AnnouncementType, blank=False, null=False, default="A"
)
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)

def __str__(self):
return self.content[:20] + "..."


class Invite(models.Model):
inviting_team = models.ForeignKey(
Team, on_delete=models.CASCADE, related_name="invite_to_team"
)
invite_email = models.EmailField(blank=False, null=False)

def __str__(self):
return self.invite_email
return self.invite_email
Loading

0 comments on commit 90103f1

Please sign in to comment.