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

Release #35

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
exclude = venv, migrations
exclude = venv, migrations, .venv, .env
max-line-length = 88
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@ Students attendance report [page](https://attendancebackend-v9zk.onrender.com/a

## Code contribution

### Lint & Formatting
We use `flake8==6.1.0` as a linter and `black==23.11.0` as a code formatter

Install
```bash
pip install flake8==6.1.0 black==23.11.0
```

Run black
```bash
black .
```

Run flake8
```bash
flake8 .
```

## Setup

### Using python.
Expand All @@ -49,8 +31,32 @@ python manage.py migrate
python manage.py runserver
```

After that you have to create superuser and create some dummy data.
Dummy data can be created using django Fixtures if you are interested raise a PR for that.
After that you can load dummy data. Run below command in a different shell.
```bash
python manage.py loaddata ./fixture.json
```

After loading fixtures you can use following credencials to loggin
username: [email protected]
password: password

### Lint & Formatting
We use `flake8==6.1.0` as a linter and `black==23.11.0` as a code formatter

Install
```bash
pip install flake8==6.1.0 black==23.11.0
```

Run black
```bash
black .
```

Run flake8
```bash
flake8 .
```

### To build an image.
```bash
Expand Down
35 changes: 35 additions & 0 deletions attendance/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from django.urls import reverse
from attendance.models import (
Student,
StudentGroup,
StudentGroupItem,
Subject,
SubjectClass,
ClassAttendance,
Expand All @@ -11,6 +13,7 @@
FalseAttemptGeoLocation,
ClassAttendanceByBSM,
ProblemSolvingPercentage,
SubjectClassStudentGroups,
)
from django.utils.html import format_html

Expand Down Expand Up @@ -158,7 +161,13 @@ def send_notification(self, obj):
send_notification.short_description = "Send Reminder"


class SubjectClassStudentGroupsInline(admin.TabularInline):
model = SubjectClassStudentGroups
autocomplete_fields = ["student_group"]


class SubjectClassAdmin(admin.ModelAdmin):
inlines = [SubjectClassStudentGroupsInline]
list_display = (
"__str__",
"subject",
Expand Down Expand Up @@ -262,6 +271,32 @@ def send_reminder(self, obj):
)


class StudentGroupItemInline(admin.TabularInline):
model = StudentGroupItem
autocomplete_fields = ["student"]


class StudentGroupAdmin(admin.ModelAdmin):
inlines = [StudentGroupItemInline]
search_fields = ["name"]
readonly_fields = ("add_bulk_candidates",)

def add_bulk_candidates(self, obj):
from django.utils.html import format_html

if obj.pk:
return format_html(
'<a class="button" target="_blank" href="{}">Add bulk students</a>',
reverse("student_group", args=[obj.pk]),
)
else:
return format_html(
'<a class="button" target="_blank" disabled>Add bulk students</a>'
)


# admin.site.register(SubjectClassStudentGroups)
admin.site.register(StudentGroup, StudentGroupAdmin)
admin.site.register(ProblemSolvingPercentage, ProblemSolvingPercentageAdmin)
admin.site.register(ClassAttendanceByBSM, ClassAttendanceByBSMAdmin)
admin.site.register(Student, StudentAdmin)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Generated by Django 4.2.8 on 2024-02-25 11:30

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


class Migration(migrations.Migration):
dependencies = [
("attendance", "0056_alter_classattendance_options"),
]

operations = [
migrations.CreateModel(
name="StudentGroup",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name="StudentGroupItem",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("join_date", models.DateTimeField(auto_now_add=True)),
(
"student",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="attendance.student",
),
),
(
"student_group",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="attendance.studentgroup",
),
),
],
),
migrations.AddField(
model_name="studentgroup",
name="students",
field=models.ManyToManyField(
through="attendance.StudentGroupItem", to="attendance.student"
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.8 on 2024-02-25 12:05

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("attendance", "0057_studentgroup_studentgroupitem_studentgroup_students"),
]

operations = [
migrations.AlterUniqueTogether(
name="studentgroupitem",
unique_together={("student", "student_group")},
),
]
54 changes: 54 additions & 0 deletions attendance/migrations/0059_subjectclassstudentgroups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Generated by Django 4.2.8 on 2024-02-25 12:25

import attendance.models
from django.db import migrations, models
import django.db.models.deletion
import enumfields.fields


class Migration(migrations.Migration):
dependencies = [
("attendance", "0058_alter_studentgroupitem_unique_together"),
]

operations = [
migrations.CreateModel(
name="SubjectClassStudentGroups",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"attendance_policy",
enumfields.fields.EnumField(
default=0,
enum=attendance.models.AttendanceStatus,
max_length=10,
),
),
(
"student_group",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="attendance.studentgroup",
),
),
(
"subject_class",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="attendance.subjectclass",
),
),
],
options={
"unique_together": {("subject_class", "student_group")},
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.8 on 2024-02-25 12:28

import attendance.models
from django.db import migrations
import enumfields.fields


class Migration(migrations.Migration):
dependencies = [
("attendance", "0059_subjectclassstudentgroups"),
]

operations = [
migrations.AlterField(
model_name="subjectclassstudentgroups",
name="attendance_policy",
field=enumfields.fields.EnumField(
default=0,
enum=attendance.models.SubjectClassStudentGroups.AttendancePolicy,
max_length=10,
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.8 on 2024-06-16 09:53

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("attendance", "0060_alter_subjectclassstudentgroups_attendance_policy"),
]

operations = [
migrations.AlterField(
model_name="subjectclass",
name="is_attendance_by_geo_location_enabled",
field=models.BooleanField(default=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.8 on 2024-06-16 09:55

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("attendance", "0061_alter_subjectclass_is_attendance_by_geo_location_enabled"),
]

operations = [
migrations.AlterField(
model_name="subjectclass",
name="is_attendance_mandatory",
field=models.BooleanField(default=True, help_text="dont use this field"),
),
]
Loading
Loading