forked from beba/foerderbarometer
prettifying the otrs links as wished through a javascript function onload, in /static/dropdown/js/otrs_link.js
This commit is contained in:
parent
1454fce9ba
commit
a51552d4dd
|
@ -36,6 +36,10 @@ 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):
|
||||||
|
|
|
@ -102,10 +102,6 @@ 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 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):
|
def save(self,*args,**kwargs):
|
||||||
'''we generate the autogenerated fields here'''
|
'''we generate the autogenerated fields here'''
|
||||||
|
|
|
@ -2,9 +2,16 @@ window.addEventListener("load", function() {
|
||||||
(function($) {
|
(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, "=");
|
||||||
|
|
||||||
html.body.style.backgroundColor = color[red];
|
console.log(otrs_link_pretty);
|
||||||
|
|
||||||
|
document.querySelector(".field-otrs > div > p.url > a").href = otrs_link_pretty;
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue