Fakultas Ilmu Komputer UI

Commit 9816bf33 authored by Ryan Karyadiputera's avatar Ryan Karyadiputera
Browse files

test3

parent 8a6d5e92
Pipeline #81578 passed with stage
in 2 minutes and 30 seconds
......@@ -122,21 +122,21 @@ class LaporanAkhirPraktikum(AttributeLaporanPraktikum):
profil_lembaga = models.FileField(blank=True, null=True)
umpan_balik = models.CharField(max_length=255, blank=True, default=" ")
def getLembagaID(self):
return self.lembaga.id
# def getLembagaID(self):
# return self.lembaga.id
def updateTahun(self):
currentYear = self.lembaga.last_activity
newYear = self.periode_praktikum[:4]
if newYear != '' and (currentYear == None or currentYear < int(newYear)):
return newYear
# def updateTahun(self):
# currentYear = self.lembaga.last_activity
# newYear = self.periode_praktikum[:4]
# if newYear != '' and (currentYear == None or currentYear < int(newYear)):
# return newYear
else:
return currentYear
# else:
# return currentYear
def save(self, *args, **kwargs):
Lembaga.objects.filter(id = self.getLembagaID()).update(last_activity = self.updateTahun())
super().save(*args,**kwargs)
# def save(self, *args, **kwargs):
# Lembaga.objects.filter(id = self.getLembagaID()).update(last_activity = self.updateTahun())
# super().save(*args,**kwargs)
def __str__(self): # pragma: no cover
return self.nama_laporan
......
# Generated by Django 3.1.3 on 2021-06-06 13:37
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('lembaga', '0006_lembaga_last_activity'),
]
operations = [
migrations.RemoveField(
model_name='lembaga',
name='last_activity',
),
]
......@@ -35,7 +35,7 @@ class Lembaga(models.Model):
beneficaries = models.CharField(max_length=1024)
alamat = models.CharField(max_length=1024)
praktikum_ke = models.IntegerField()
last_activity = models.IntegerField('last activity', blank=True, null=True)
# last_activity = models.IntegerField('last activity', blank=True, null=True)
def __str__(self):
return self.nama
......
......@@ -75,7 +75,7 @@ class LembagaSerializer(serializers.ModelSerializer):
praktikum_ke = validated_data.pop('praktikum_ke')
beneficaries = validated_data.pop('beneficaries')
alamat = validated_data.pop('alamat')
last_activity = validated_data.pop('last_activity')
# last_activity = validated_data.pop('last_activity')
nama_tema = validated_data.pop('tema')['nama']
......@@ -99,7 +99,7 @@ class LembagaSerializer(serializers.ModelSerializer):
lembaga.praktikum_ke = praktikum_ke
lembaga.beneficaries = beneficaries
lembaga.alamat = alamat
lembaga.last_activity = last_activity
# lembaga.last_activity = last_activity
lembaga.save()
......
......@@ -13,12 +13,12 @@ from django_filters.rest_framework import DjangoFilterBackend
def get_lembaga(request, time):
# current_year = 2021
if (time == "newer"):
supervisor_lembaga = Lembaga.objects.filter(last_activity = 0)
# supervisor_lembaga2 = Lembaga.objects.filter(last_activity = None)
# supervisor_lembaga = supervisor_lembaga1 | supervisor_lembaga2
elif (time == "older"):
supervisor_lembaga = Lembaga.objects.filter(last_activity = 0)
# if (time == "newer"):
# supervisor_lembaga = Lembaga.objects.filter(last_activity = 0)
# # supervisor_lembaga2 = Lembaga.objects.filter(last_activity = None)
# # supervisor_lembaga = supervisor_lembaga1 | supervisor_lembaga2
# elif (time == "older"):
supervisor_lembaga = Lembaga.objects.all()
serializer = LembagaSerializer(supervisor_lembaga, context={'request': request}, many=True)
response = serializer.data
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment