Skip to content

Commit

Permalink
Merge branch 'migrating-pages' of https://github.com/imApoorva36/corpus
Browse files Browse the repository at this point in the history
… into migrating-pages
  • Loading branch information
imApoorva36 committed Jan 19, 2024
2 parents 89b9f5a + 69b79c2 commit e99016d
Show file tree
Hide file tree
Showing 44 changed files with 806 additions and 515 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.7 on 2024-01-16 04:31
import datetime

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


class Migration(migrations.Migration):

dependencies = [
("accounts", "0002_alter_user_email_alter_user_phone_no_executivemember"),
]

operations = [
migrations.AlterField(
model_name="executivemember",
name="date_joined",
field=models.DateTimeField(
default=datetime.datetime(2024, 1, 16, 10, 1, 4, 787196),
verbose_name="Date Joined",
),
),
]
8 changes: 6 additions & 2 deletions corpus/electrika/admin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from django.contrib import admin

from .models import Announcement
from .models import ElectrikaUser
from .models import Invite
from .models import Team

# 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)
admin.site.register(Invite)
4 changes: 2 additions & 2 deletions corpus/electrika/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


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

from corpus.forms import CorpusModelForm


class ElectrikaForm(CorpusModelForm):
class Meta:
model = ElectrikaUser
Expand All @@ -19,21 +24,23 @@ 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"
"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):

class AnnouncementForm(CorpusModelForm):
ANNOUNCEMENT_OPTIONS = [
("1", "No email to be sent."),
("2", "Send email to all team leaders."),
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"]
140 changes: 107 additions & 33 deletions corpus/electrika/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-15 08:43

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,53 +15,127 @@ 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 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)),
(
"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',
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)),
(
"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',
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')),
(
"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',
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')),
(
"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'),
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),
model_name="electrikauser",
name="user",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
]
19 changes: 12 additions & 7 deletions corpus/electrika/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.db import models
from embedathon.models import PAYMENT_STATUS
from accounts.models import User
from django.db import models


class ElectrikaUser(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Expand All @@ -18,17 +18,19 @@ class ElectrikaUser(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(
ElectrikaUser, on_delete=models.CASCADE, related_name="leader"
)

def __str__(self):
return self.team_name

class Announcement(models.Model):


class Announcement(models.Model):
AnnouncementType = (
("A", "All Electrika Users"),
("T", "All Electrika Teams"),
Expand All @@ -38,18 +40,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=2, choices=AnnouncementType, blank=False, null=False, default="A")
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
return self.invite_email
6 changes: 3 additions & 3 deletions corpus/electrika/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from django.test import TestCase

# Create your tests here.
# from django.test import TestCase
#
# # Create your tests here.
22 changes: 9 additions & 13 deletions corpus/electrika/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.urls import path

from . import views

urlpatterns = [
Expand All @@ -7,17 +8,17 @@
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("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/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(
Expand All @@ -30,9 +31,4 @@
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 e99016d

Please sign in to comment.