Ajout de présence de remarques sur la page de recherche
This commit is contained in:
@@ -23,7 +23,7 @@ class Collabs_hour_Admin(admin.ModelAdmin):
|
||||
class Meta:
|
||||
verbose_name = 'Heure supplémentaire'
|
||||
verbose_name_plural = 'Heures supplémentaires'
|
||||
list_display = ('dtDate','nHour', 'nMinutes', 'user', 'sBases', 'type','get_total_hour_by_user', 'bNoticed')
|
||||
list_display = ('dtDate','nHour', 'nMinutes', 'user', 'sBases', 'get_total_hour_by_user','has_remarques', 'bNoticed')
|
||||
list_editable = ['bNoticed']
|
||||
list_filter = [('dtDate', DateRangeFilter), ('user', admin.RelatedOnlyFieldListFilter),'sBases','type']
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import datetime
|
||||
import math
|
||||
import time
|
||||
|
||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||
from django.db import models
|
||||
@@ -8,22 +7,6 @@ from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
class Collabs_hour_types(models.Model):
|
||||
|
||||
|
||||
name = models.CharField("Dénomination", max_length=100)
|
||||
dtUpdate = models.DateTimeField('Date de modification', auto_now=True)
|
||||
dtCreated = models.DateTimeField('Date de création', auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = "type"
|
||||
verbose_name_plural = "types"
|
||||
|
||||
|
||||
class Collabs_hour(models.Model):
|
||||
|
||||
BASES_CHOICES = [
|
||||
@@ -32,14 +15,13 @@ class Collabs_hour(models.Model):
|
||||
]
|
||||
|
||||
userName = models.CharField("Auteur", max_length=100)
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, limit_choices_to={'groups__name': "Intervenants"}, verbose_name="Collaborateur", on_delete=models.DO_NOTHING)
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name="Collaborateur", on_delete=models.DO_NOTHING, default=0)
|
||||
nHour = models.PositiveIntegerField("Heures", default=0, validators=[MinValueValidator(0), MaxValueValidator(23)])
|
||||
nMinutes = models.PositiveIntegerField("Minutes", default=0, validators=[MinValueValidator(0), MaxValueValidator(60)])
|
||||
sRemarques = models.TextField("Remarques", blank=True)
|
||||
bNoticed = models.BooleanField("Vérifiée", blank=True, default=False)
|
||||
dtDate = models.DateField('Date', blank=False)
|
||||
sBases = models.CharField('Employé de la base de', max_length=1, choices=BASES_CHOICES,default=1)
|
||||
type = models.ForeignKey(Collabs_hour_types, verbose_name="Types", on_delete=models.DO_NOTHING)
|
||||
dtUpdate = models.DateTimeField('Date de modification', auto_now=True)
|
||||
dtCreated = models.DateTimeField('Date de création', auto_now_add=True)
|
||||
|
||||
@@ -47,10 +29,7 @@ class Collabs_hour(models.Model):
|
||||
|
||||
@admin.display( description='Total du mois')
|
||||
def get_total_hour_by_user(self):
|
||||
#objs = Collabs_hour.objects.filter(user_id=self.user_id,dtCreated__year=self.dtCreated.year, dtCreated__month=self.dtCreated.month)
|
||||
objs = Collabs_hour.objects.filter(user_id=self.user_id, dtCreated__year=self.dtCreated.year , dtCreated__month=self.dtCreated.month)
|
||||
print(f"user {self.user} dtCreated__year {self.dtCreated.year} dtCreated__month {self.dtCreated.month}")
|
||||
print( Collabs_hour.objects.all())
|
||||
objs = Collabs_hour.objects.filter(user=self.user,dtCreated__year=self.dtCreated.year, dtCreated__month=self.dtCreated.month)
|
||||
|
||||
total = 0.0
|
||||
|
||||
@@ -60,26 +39,23 @@ class Collabs_hour(models.Model):
|
||||
|
||||
|
||||
print(total)
|
||||
print(objs)
|
||||
if total > 0.0:
|
||||
hours = int(total)
|
||||
minutes = (total*60) % 60
|
||||
|
||||
ret_string = ("%d:%02d" % (hours, minutes))
|
||||
#ret_string = str(int(math.floor(total))) + ':' + str(int((total%(math.floor(total)))*60)) + f" ({total})"
|
||||
#ret_string = time.strftime("%H:%M", time.gmtime(total))
|
||||
else:
|
||||
ret_string = "0"
|
||||
return str(int(math.floor(total))) + ':' + str(int((total%(math.floor(total)))*60)) + f" ({total})"
|
||||
|
||||
return ret_string
|
||||
|
||||
def __str__(self):
|
||||
return f"Heure supplémentaire: {self.user} : {self.dtCreated.strftime('%d.%m.%Y')} "
|
||||
@admin.display(description='Présence de remarques', boolean=True)
|
||||
def has_remarques(self):
|
||||
ret = False
|
||||
if self.sRemarques != None and self.sRemarques != '':
|
||||
ret = True
|
||||
return ret
|
||||
|
||||
class Meta:
|
||||
verbose_name = "heure supplémentaire"
|
||||
verbose_name_plural = "heures supplémentaires"
|
||||
verbose_name = "heure suplémentaire"
|
||||
verbose_name_plural = "heures suplémentaires"
|
||||
permissions = (
|
||||
("can_notice", "Peut noter comme traitée"),
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user