Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add projects expo #143

Merged
merged 13 commits into from
Mar 21, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.7 on 2024-03-21 05:30
import datetime

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


class Migration(migrations.Migration):

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

operations = [
migrations.AlterField(
model_name="executivemember",
name="date_joined",
field=models.DateTimeField(
default=datetime.datetime(
2024, 3, 21, 5, 30, 54, 960770, tzinfo=datetime.timezone.utc
),
verbose_name="Date Joined",
),
),
migrations.AlterField(
model_name="executivemember",
name="github",
field=models.CharField(
blank=True, max_length=39, null=True, verbose_name="GitHub Username"
),
),
]
7 changes: 3 additions & 4 deletions corpus/accounts/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from datetime import datetime

from config.models import SIG
from django.contrib.auth.base_user import BaseUserManager
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils import timezone
from django.utils.translation import gettext_lazy as _

from .validators import validate_ieee_email
Expand Down Expand Up @@ -137,11 +136,11 @@ class ExecutiveMember(models.Model):

# TODO: Phase out with GitHub OAuth details
github = models.CharField(
max_length=200, blank=True, null=True, verbose_name="GitHub Username"
max_length=39, blank=True, null=True, verbose_name="GitHub Username"
)
is_nep = models.BooleanField(default=False, verbose_name="Is NEP Member?")
date_joined = models.DateTimeField(
default=datetime.now(), verbose_name="Date Joined"
default=timezone.now(), verbose_name="Date Joined"
)

def save(self, *args, **kwargs):
Expand Down
23 changes: 23 additions & 0 deletions corpus/corpus/decorators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from accounts.models import ExecutiveMember
from config.models import ModuleConfiguration
from django.contrib import messages
from django.shortcuts import redirect
Expand Down Expand Up @@ -53,3 +54,25 @@ def wrapper(request, *args, **kwargs):
return wrapper

return decorator


def ensure_exec_membership():
def decorator(view_func):
def wrapper(request, *args, **kwargs):
try:
exec_member = ExecutiveMember.objects.get(user=request.user.id)
request.exec_member = exec_member
return view_func(request, *args, **kwargs)
except ExecutiveMember.DoesNotExist:
messages.error(
request,
"""
Permission denied.
Please contact the administrators if you think there is an issue.
""",
)
return redirect("index")

return wrapper

return decorator
6 changes: 6 additions & 0 deletions corpus/corpus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"ckeditor",
"ckeditor_uploader",
"pages.apps.PagesConfig",
"config.apps.ConfigConfig",
"accounts.apps.AccountsConfig",
Expand All @@ -63,6 +65,7 @@
"skyward_expedition.apps.SkywardExpeditionConfig",
"robotrix.apps.RobotrixConfig",
"farewell.apps.FarewellConfig",
"virtual_expo.apps.VirtualExpoConfig",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -207,3 +210,6 @@
)
except Exception:
raise ImproperlyConfigured("Django Sentry DSN Not found!")

CKEDITOR_UPLOAD_PATH = "ckeditor_uploads/"
CKEDITOR_RESTRICT_BY_USER = True
19 changes: 19 additions & 0 deletions corpus/corpus/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,26 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from ckeditor_uploader import views as ckeditor_views
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth.decorators import login_required
from django.urls import include
from django.urls import path
from django.views.decorators.cache import never_cache

urlpatterns = [
path(
"ckeditor/upload/",
login_required(ckeditor_views.upload),
name="ckeditor_upload",
),
path(
"ckeditor/browse/",
never_cache(login_required(ckeditor_views.browse)),
name="ckeditor_browse",
),
path("admin/", admin.site.urls),
path("accounts/", include("accounts.urls")),
path("", include("pages.urls")),
Expand All @@ -28,4 +43,8 @@
path("skyward_expedition/", include("skyward_expedition.urls")),
path("robotrix/", include("robotrix.urls")),
path("farewell/", include("farewell.urls")),
path("virtual_expo/", include("virtual_expo.urls")),
]

if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
6 changes: 5 additions & 1 deletion corpus/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
asgiref==3.7.2
certifi==2024.2.2
cfgv==3.4.0
distlib==0.3.8
Django==4.2.7
django-ckeditor==6.7.1
django-js-asset==2.2.0
filelock==3.13.1
gunicorn==21.2.0
identify==2.5.34
Expand All @@ -14,9 +17,10 @@ pre-commit==3.6.1
psycopg2-binary==2.9.9
python-magic==0.4.27
PyYAML==6.0.1
sentry-sdk[django]==1.40.5
sentry-sdk==1.40.5
setuptools==68.2.2
sqlparse==0.4.4
typing_extensions==4.8.0
urllib3==2.2.1
virtualenv==20.25.0
wheel==0.41.2
2 changes: 1 addition & 1 deletion corpus/templates/components/general_dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<li><a href="{% url 'about_us' %}">About Us</a></li>
<li><a href="https://ieee-nitk.github.io/blog/">Blog</a></li>
<li><a href="https://ieee-nitk.github.io/gyan/">Gyan</a></li>
<li><a href="https://ieee-nitk.github.io/virtual-expo/">Virtual Expo</a>
<li><a href="{% url 'virtual_expo_home' %}">Virtual Expo</a>
</li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion corpus/templates/components/navbar_large.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

<a href="https://ieee-nitk.github.io/blog/" class="btn btn-ghost normal-case text-lg">Blog</a>
<a href="https://ieee-nitk.github.io/gyan/" class="btn btn-ghost normal-case text-lg">Gyan</a>
<a href="https://ieee-nitk.github.io/virtual-expo/" class="btn btn-ghost normal-case text-lg">Virtual Expo</a>
<a href="{% url 'virtual_expo_home' %}" class="btn btn-ghost normal-case text-lg">Virtual Expo</a>
</div>
<div class="navbar-end">

Expand Down
82 changes: 82 additions & 0 deletions corpus/templates/virtual_expo/admin/dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{% extends "virtual_expo/base.html" %}

{% block title %}
Admin Dashboard
{{ block.super }}
{% endblock %}

{% block content %}
{% include "virtual_expo/header.html" with text="Admin Dashboard" %}
<div class="m-10">
<div class="my-2 p-5 border rounded-lg">
<form method="get">
<div class="flex flex-row gap-4">
<div class="w-full">
<label for="{{ form.report_type.id_for_label }}">Report Type</label>
{{ form.report_type }}
</div>
<div class="w-full">
<label for="{{ form.sig.id_for_label }}">SIG</label>
{{ form.sig }}
</div>
<div class="w-full">
<label for="{{ form.year.id_for_label }}">Year</label>
{{ form.year }}
</div>
<div class="w-full flex flex-row justify-center items-end">
<button type="submit" class="btn btn-primary rounded-full w-full">Filter</button>
</div>
</div>
</form>
</div>
<div class="p-5 border rounded-lg overflow-x-auto">
<table class="table">
<thead>
<tr>
<th></th>
<th>Title</th>
<th>Year</th>
<th>SIGs</th>
<th>Approval Status</th>
<th>Approver</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{% for report in reports %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ report.title }}</td>
<td>{{ report.year }}</td>
<td class="flex gap-4">
{% for sig in report.sigs %}
<div class="badge badge-secondary">{{ sig }}</div>
{% endfor %}
</td>
<td>
{% if report.approved %}
<div class="badge badge-success">Approved</div>
{% elif report.ready_for_approval %}
<div class="badge badge-info">Under Review</div>
{% else %}
<div class="badge badge-warning">Not Submitted</div>
{% endif %}
</td>
<td>{{ report.approver }}</td>
<td class="flex gap-4 justify-start items-center">
<a href="{% url 'virtual_expo_preview_report' report_id=report.id %}"
class="btn btn-primary">
Preview Report
</a>
{% if not report.approved %}
<a href="{% url 'virtual_expo_admin_manage' report_id=report.id %}"
class="btn btn-primary">Manage</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
Loading
Loading