forked from beba/foerderbarometer
Merge tag 'v3.2' of https://code.basabuuka.org/alpcentaur/foerderbarometer into HEAD
bugfixes financeID and pretty otrs links
This commit is contained in:
commit
442cd73b03
|
@ -36,6 +36,11 @@ class ProjectAdmin(admin.ModelAdmin):
|
||||||
date_hierarchy = 'end'
|
date_hierarchy = 'end'
|
||||||
readonly_fields = ('end_quartal', 'project_of_year', 'pid', 'finance_id')
|
readonly_fields = ('end_quartal', 'project_of_year', 'pid', 'finance_id')
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
js = ('dropdown/js/otrs_link.js',)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(BusinessCard)
|
@admin.register(BusinessCard)
|
||||||
class BusinessCardAdmin(admin.ModelAdmin):
|
class BusinessCardAdmin(admin.ModelAdmin):
|
||||||
save_as = True
|
save_as = True
|
||||||
|
|
|
@ -26,6 +26,9 @@ class ProjectForm(FdbForm):
|
||||||
widgets = {'start': AdminDateWidget(),
|
widgets = {'start': AdminDateWidget(),
|
||||||
'end': AdminDateWidget(),}
|
'end': AdminDateWidget(),}
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
js = ('dropdown/js/otrs_link.js',)
|
||||||
|
|
||||||
|
|
||||||
class ExternForm(FdbForm):
|
class ExternForm(FdbForm):
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
from django.utils.http import urlencode
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
|
import urllib
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
from .settings import ACCOUNTS
|
from .settings import ACCOUNTS
|
||||||
|
|
||||||
|
@ -100,13 +102,41 @@ class Project(Volunteer):
|
||||||
project_of_year = models.IntegerField(default=0)
|
project_of_year = models.IntegerField(default=0)
|
||||||
end_quartal = models.CharField(max_length=15, null=True, blank=True, verbose_name="Quartal Projekt Ende")
|
end_quartal = models.CharField(max_length=15, null=True, blank=True, verbose_name="Quartal Projekt Ende")
|
||||||
|
|
||||||
|
|
||||||
def save(self,*args,**kwargs):
|
def save(self,*args,**kwargs):
|
||||||
'''we generate the autogenerated fields here'''
|
'''we generate the autogenerated fields here'''
|
||||||
# we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors
|
# we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors
|
||||||
# but maybe there is a better solution?
|
# but maybe there is a better solution?
|
||||||
|
preotrs = self.otrs
|
||||||
|
|
||||||
|
#postotrs = ''
|
||||||
|
#for n in range(len(preotrs)):
|
||||||
|
# if preotrs[n] == ';':
|
||||||
|
# postotrs += '\;'
|
||||||
|
# else:
|
||||||
|
# postotrs += preotrs[n]
|
||||||
|
#print(self.otrs)
|
||||||
|
#print(preotrs)
|
||||||
|
#print(postotrs)
|
||||||
|
postotrs = urllib.parse.quote(preotrs, safe=':;/=?&')
|
||||||
|
self.otrs = mark_safe(urllib.parse.unquote(postotrs))
|
||||||
|
startyear_tmp = 'NONE'
|
||||||
|
|
||||||
|
if self.pid:
|
||||||
|
print('self pid last four', self.pid[:4], self.start.year)
|
||||||
|
if int(self.pid[:4]) != int(self.start.year):
|
||||||
|
startyear_tmp = self.start.year
|
||||||
|
|
||||||
|
print('the startyear_tmp is as follows ', startyear_tmp)
|
||||||
|
|
||||||
super().save()
|
super().save()
|
||||||
self.pid = str(self.start.year) + '-' + str(self.account.code) + str(self.pk).zfill(3)
|
|
||||||
# self.pid = str(self.account.code) + str(self.pk).zfill(3)
|
if startyear_tmp == 'NONE':
|
||||||
|
|
||||||
|
self.pid = str(self.start.year) + '-' + str(self.account.code) + str(self.pk).zfill(3)
|
||||||
|
# self.pid = str(self.account.code) + str(self.pk).zfill(3)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# generation of field quartals
|
# generation of field quartals
|
||||||
if self.end.month in [1, 2, 3]:
|
if self.end.month in [1, 2, 3]:
|
||||||
|
@ -119,13 +149,25 @@ class Project(Volunteer):
|
||||||
self.end_quartal = 'Q4'
|
self.end_quartal = 'Q4'
|
||||||
|
|
||||||
# generation of pid and financeID
|
# generation of pid and financeID
|
||||||
|
# project of year is true if entry gets updated with changes.. but year can change!!!!!!!!
|
||||||
|
if self.project_of_year:
|
||||||
|
print('oi oi oi oi oi')
|
||||||
|
print(self.pid)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# project of year is false if entry gets saved as new
|
||||||
|
if not self.project_of_year or startyear_tmp != 'NONE':
|
||||||
|
print('AAA')
|
||||||
|
|
||||||
|
print('self projekt of year', self.project_of_year, self.start.year)
|
||||||
|
|
||||||
if not self.project_of_year:
|
|
||||||
#print('AAA')
|
|
||||||
# we need to determine if this is a new year with its first new project...
|
# we need to determine if this is a new year with its first new project...
|
||||||
year = self.start.year
|
year = self.start.year
|
||||||
#print(year)
|
#print(year)
|
||||||
projects = Project.objects.filter(start__year=year)
|
projects = Project.objects.filter(start__year=year)
|
||||||
|
print('projects after filter of startyear of project',projects)
|
||||||
if not projects:
|
if not projects:
|
||||||
#print('BBB')
|
#print('BBB')
|
||||||
self.project_of_year = 1
|
self.project_of_year = 1
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
window.addEventListener("load", function() {
|
||||||
|
(function($) {
|
||||||
|
$(function() {
|
||||||
|
|
||||||
|
let otrs_link = document.querySelector(".field-otrs > div > p.url > a").href;
|
||||||
|
console.log(otrs_link);
|
||||||
|
alert(otrs_link);
|
||||||
|
|
||||||
|
let otrs_link_pret = otrs_link.replace(/%3B/g, ";");
|
||||||
|
let otrs_link_pretty = otrs_link_pret.replace(/%3D/g, "=");
|
||||||
|
|
||||||
|
console.log(otrs_link_pretty);
|
||||||
|
|
||||||
|
document.querySelector(".field-otrs > div > p.url > a").href = otrs_link_pretty;
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
})(django.jQuery);
|
||||||
|
});
|
Loading…
Reference in New Issue