Skip to content

Commit

Permalink
Merge branch 'main' into seo-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
imApoorva36 authored Feb 19, 2024
2 parents 4abe79f + 62f4767 commit 65c9ba5
Show file tree
Hide file tree
Showing 26 changed files with 2,494 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.4 on 2024-01-24 13:40
import datetime

from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = [
("accounts", "0003_alter_executivemember_date_joined"),
]

operations = [
migrations.AlterField(
model_name="executivemember",
name="date_joined",
field=models.DateTimeField(
default=datetime.datetime(2024, 1, 24, 19, 10, 0, 912845),
verbose_name="Date Joined",
),
),
]
5 changes: 3 additions & 2 deletions corpus/corpus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = (os.getenv("ENVIRONMENT") == "DEVELOPMENT") or (
os.getenv("LIVECYCLE") is not None
os.getenv("LIVECYCLE") is not None
)

# TODO: Stricter host policies
Expand Down Expand Up @@ -57,7 +57,8 @@
"embedathon.apps.EmbedathonConfig",
"impulse.apps.ImpulseConfig",
"electrika.apps.ElectrikaConfig",
"skyward_expedition.apps.SkywardExpeditionConfig"
"skyward_expedition.apps.SkywardExpeditionConfig",
"robotrix.apps.RobotrixConfig",
]

MIDDLEWARE = [
Expand Down
1 change: 1 addition & 0 deletions corpus/corpus/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
path("impulse/", include("impulse.urls")),
path("electrika/", include("electrika.urls")),
path("skyward_expedition/", include("skyward_expedition.urls")),
path("robotrix/", include("robotrix.urls")),
]
4 changes: 2 additions & 2 deletions corpus/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
asgiref==3.7.2
Django==4.2.7
Django==4.2.10
gunicorn==21.2.0
packaging==23.1
Pillow==10.0.1
Pillow==10.2.0
psycopg2-binary==2.9.9
sqlparse==0.4.4
typing_extensions==4.8.0
Empty file added corpus/robotrix/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions corpus/robotrix/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.contrib import admin
from robotrix.models import Announcement
from robotrix.models import Invite
from robotrix.models import RobotrixUser
from robotrix.models import Team

# Register your models here.

admin.site.register(RobotrixUser)
admin.site.register(Team)
admin.site.register(Announcement)
admin.site.register(Invite)
6 changes: 6 additions & 0 deletions corpus/robotrix/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class RobotrixConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "robotrix"
69 changes: 69 additions & 0 deletions corpus/robotrix/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from django import forms
from robotrix.models import Announcement
from robotrix.models import Invite
from robotrix.models import RobotrixUser
from robotrix.models import Team

from corpus.forms import CorpusModelForm


class RobotrixForm(CorpusModelForm):
class Meta:
model = RobotrixUser
fields = [
"from_nitk",
"college_name",
"roll_no",
"ieee_member",
"ieee_membership_no",
"phone_no",
]

def clean(self):
data = self.cleaned_data
if data.get("from_nitk", None) and not data.get("roll_no", None):
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 = [
("1", "No email to be sent."),
("2", "Send email to all team leaders."),
("3", "Send email to all members"),
]

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",
]


class InviteForm(CorpusModelForm):
class Meta:
model = Invite
fields = ["invite_email"]
160 changes: 160 additions & 0 deletions corpus/robotrix/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Generated by Django 4.2.4 on 2024-02-18 14:33
import django.db.models.deletion
from django.conf import settings
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
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 Robotrix Users"),
("P", "Paid Teams"),
("U", "Unpaid Teams"),
("N", "Registered for Robotrix but no team"),
("NI", "Not Registered for Robotrix"),
],
default="A",
max_length=2,
),
),
("date_created", models.DateTimeField(auto_now_add=True)),
("date_modified", models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name="RobotrixUser",
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)),
(
"phone_no",
models.CharField(
max_length=15, unique=True, verbose_name="Phone Number"
),
),
],
),
migrations.CreateModel(
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,
),
),
(
"team_leader",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="leader",
to="robotrix.robotrixuser",
),
),
],
),
migrations.AddField(
model_name="robotrixuser",
name="team",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="team",
to="robotrix.team",
),
),
migrations.AddField(
model_name="robotrixuser",
name="user",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
migrations.CreateModel(
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="robotrix.team",
),
),
],
),
]
Empty file.
72 changes: 72 additions & 0 deletions corpus/robotrix/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from accounts.models import User
from django.db import models
from embedathon.models import PAYMENT_STATUS


class RobotrixUser(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
from_nitk = models.BooleanField(default=True)
college_name = models.CharField(
max_length=200, default="National Institute of Technology Karnataka"
)
roll_no = models.CharField(max_length=8, blank=True, null=True)
ieee_member = models.BooleanField(default=False)
ieee_membership_no = models.BigIntegerField(blank=True, null=True)
phone_no = models.CharField(
max_length=15,
unique=True,
verbose_name="Phone Number",
)
team = models.ForeignKey(
"Team", on_delete=models.CASCADE, related_name="team", blank=True, null=True
)

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(
RobotrixUser, on_delete=models.CASCADE, related_name="leader"
)

payment_status = models.CharField(
max_length=1, choices=PAYMENT_STATUS, blank=False, null=False, default="U"
)

def __str__(self):
return self.team_name


class Announcement(models.Model):

AnnouncementType = (
("A", "All Robotrix Users"),
("P", "Paid Teams"),
("U", "Unpaid Teams"),
("N", "Registered for Robotrix but no team"),
("NI", "Not Registered for Robotrix"),
)

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=2, 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
Loading

0 comments on commit 65c9ba5

Please sign in to comment.