Browse Source

prettifying the otrs links as wished through a javascript function onload, in /static/dropdown/js/otrs_link.js

master v3.2
alpcentaur 10 months ago
parent
commit
a51552d4dd
3 changed files with 14 additions and 7 deletions
  1. +4
    -0
      input/admin.py
  2. +0
    -4
      input/models.py
  3. +10
    -3
      input/static/dropdown/js/otrs_link.js

+ 4
- 0
input/admin.py View File

@ -36,6 +36,10 @@ class ProjectAdmin(admin.ModelAdmin):
date_hierarchy = 'end'
readonly_fields = ('end_quartal', 'project_of_year', 'pid', 'finance_id')
class Media:
js = ('dropdown/js/otrs_link.js',)
@admin.register(BusinessCard)
class BusinessCardAdmin(admin.ModelAdmin):

+ 0
- 4
input/models.py View File

@ -102,10 +102,6 @@ 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'''

+ 10
- 3
input/static/dropdown/js/otrs_link.js View File

@ -2,10 +2,17 @@ window.addEventListener("load", function() {
(function($) {
$(function() {
html.body.style.backgroundColor = color[red];
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…
Cancel
Save