Browse Source

corrected small error regarding pid financeid bug fix, started javascript manipulation to get browsers to not translate url to url encoded characters for otrs link bug fix

master
alpcentaur 10 months ago
parent
commit
1454fce9ba
4 changed files with 41 additions and 2 deletions
  1. +1
    -0
      input/admin.py
  2. +3
    -0
      input/forms.py
  3. +25
    -2
      input/models.py
  4. +12
    -0
      input/static/dropdown/js/otrs_link.js

+ 1
- 0
input/admin.py View File

@ -36,6 +36,7 @@ class ProjectAdmin(admin.ModelAdmin):
date_hierarchy = 'end'
readonly_fields = ('end_quartal', 'project_of_year', 'pid', 'finance_id')
@admin.register(BusinessCard)
class BusinessCardAdmin(admin.ModelAdmin):
save_as = True

+ 3
- 0
input/forms.py View File

@ -26,6 +26,9 @@ class ProjectForm(FdbForm):
widgets = {'start': AdminDateWidget(),
'end': AdminDateWidget(),}
class Media:
js = ('dropdown/js/otrs_link.js',)
class ExternForm(FdbForm):

+ 25
- 2
input/models.py View File

@ -1,7 +1,9 @@
from datetime import date
from django.utils.http import urlencode
from django.db import models
from django.utils.html import format_html
import urllib
from django.utils.safestring import mark_safe
from .settings import ACCOUNTS
@ -100,16 +102,37 @@ class Project(Volunteer):
project_of_year = models.IntegerField(default=0)
end_quartal = models.CharField(max_length=15, null=True, blank=True, verbose_name="Quartal Projekt Ende")
def some_otrs(self):
""" This returns a HTML anchor (hyperlink) to somewhere """
return u'<a href="%s">Link</a>' % self.otrs
some_otrs.allow_tags = True
def save(self,*args,**kwargs):
'''we generate the autogenerated fields here'''
# we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors
# 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:
if self.pid[:4] != self.start.year:
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()
if startyear_tmp == 'NONE':

+ 12
- 0
input/static/dropdown/js/otrs_link.js View File

@ -0,0 +1,12 @@
window.addEventListener("load", function() {
(function($) {
$(function() {
html.body.style.backgroundColor = color[red];
});
})(django.jQuery);
});

Loading…
Cancel
Save