-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from Vignaraj-pai/electrika_2024
Electrika 2024
- Loading branch information
Showing
33 changed files
with
3,204 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) | ||
] |
Oops, something went wrong.