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
3 changed files with 14 additions and 7 deletions
|
@ -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):
|
||||
|
|
|
@ -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'''
|
||||
|
|
|
@ -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…
Reference in a new issue