Skip to content

Commit

Permalink
Merge pull request #94 from Vignaraj-pai/electrika_2024
Browse files Browse the repository at this point in the history
Electrika 2024
  • Loading branch information
anirudhprabhakaran3 authored Jan 15, 2024
2 parents 104f07f + 9fd9bd6 commit 46e3507
Show file tree
Hide file tree
Showing 33 changed files with 3,204 additions and 3 deletions.
1 change: 1 addition & 0 deletions corpus/corpus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"accounts.apps.AccountsConfig",
"embedathon.apps.EmbedathonConfig",
"impulse.apps.ImpulseConfig",
"electrika.apps.ElectrikaConfig",
]

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 @@ -24,4 +24,5 @@
path("accounts/", include("accounts.urls")),
path("embedathon/", include("embedathon.urls")),
path("impulse/", include("impulse.urls")),
path("electrika/", include("electrika.urls")),
]
Empty file added corpus/electrika/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions corpus/electrika/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.contrib import admin

# Register your models here.
from .models import ElectrikaUser, Team, Announcement, Invite

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


class ElectrikaConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'electrika'
53 changes: 53 additions & 0 deletions corpus/electrika/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from electrika.models import ElectrikaUser, Team, Announcement, Invite
from django import forms
from corpus.forms import CorpusModelForm

class ElectrikaForm(CorpusModelForm):
class Meta:
model = ElectrikaUser
fields = [
"from_nitk",
"college_name",
"roll_no",
"ieee_member",
"ieee_membership_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"]
67 changes: 67 additions & 0 deletions corpus/electrika/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Generated by Django 4.2.7 on 2024-01-15 08:43

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


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 Electrika Users'), ('T', 'All Electrika Teams'), ('N', 'Registered for Electrika but no team')], default='A', max_length=2)),
('date_created', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name='ElectrikaUser',
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)),
('to_be_teamed_up', models.BooleanField(default=False)),
],
),
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)),
('team_leader', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='leader', to='electrika.electrikauser')),
],
),
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='electrika.team')),
],
),
migrations.AddField(
model_name='electrikauser',
name='team',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='team', to='electrika.team'),
),
migrations.AddField(
model_name='electrikauser',
name='user',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]
Empty file.
55 changes: 55 additions & 0 deletions corpus/electrika/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from django.db import models
from embedathon.models import PAYMENT_STATUS
from accounts.models import User

class ElectrikaUser(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)
team = models.ForeignKey(
"Team", on_delete=models.CASCADE, related_name="team", blank=True, null=True
)
to_be_teamed_up = models.BooleanField(default=False)

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(
ElectrikaUser, on_delete=models.CASCADE, related_name="leader"
)
def __str__(self):
return self.team_name

class Announcement(models.Model):

AnnouncementType = (
("A", "All Electrika Users"),
("T", "All Electrika Teams"),
("N", "Registered for Electrika but no team"),
)

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
3 changes: 3 additions & 0 deletions corpus/electrika/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
38 changes: 38 additions & 0 deletions corpus/electrika/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from django.urls import path
from . import views

urlpatterns = [
path("", views.home, name="electrika_home"),
path("index", views.index, name="electrika_index"),
path("register", views.register, name="electrika_register"),
path("create_team", views.create_team, name="electrika_create_team"),
path("create_invite", views.create_invite, name="electrika_create_invite"),
path(
"accept_invite/<int:pk>", views.accept_invite, name="electrika_accept_invite"
),
path(
"delete_invite/<int:pk>", views.delete_invite, name="electrika_delete_invite"
),
path("teamify/optin", views.opt_in, name="electrika_opt_in"),
path("teamify/optout", views.opt_out, name="electrika_opt_out"),
path("admin", views.admin, name="electrika_admin"),
path("admin/teams", views.team_management, name="electrika_admin_teams"),
path("admin/teams/create", views.create_team_admin, name="electrika_admin_team_create"),
path("admin/team/<int:pk>", views.team_page, name="electrika_admin_team_page"),
path("admin/users", views.user_management, name="electrika_admin_users"),
path(
"admins/announcements",
views.announcements_management,
name="electrika_announcements",
),
path(
"admin/announcements/delete/<int:pk>",
views.delete_announcement,
name="electrika_delete_announcement",
),
path(
"admin/team/download_csv",
views.team_download,
name="electrika_admin_download_teams_csv",
)
]
Loading

0 comments on commit 46e3507

Please sign in to comment.