remove unused templatetags: users_tags and common_tags

parent f3647ea4
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -396,4 +394,4 @@ $(document).ready(function () {
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load static %}
{% load i18n %}
......
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -395,4 +393,4 @@ $(document).ready(function () {
})
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends '_base_list.html' %}
{% load i18n %}
{% load static %}
{% load common_tags %}
{% block custom_head_css_js %}
<link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
......@@ -325,4 +324,4 @@ $(document).ready(function(){
$('#asset_bulk_update_modal').modal('hide');
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -276,4 +274,4 @@ $(document).ready(function () {
deleteTagAssets($this, name, the_url, data);
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends '_base_list.html' %}
{% load i18n static %}
{#{% load common_tags %}#}
{% block custom_head_css_js %}
<link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
......@@ -123,4 +122,4 @@ $(document).ready(function () {
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -365,4 +363,4 @@ $(document).ready(function () {
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -156,4 +154,4 @@ $(document).ready(function () {
idcDelete(name, the_url);
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -370,4 +368,4 @@ $(document).ready(function () {
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -133,4 +131,4 @@
$('.select2').select2();
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -184,4 +182,4 @@
$('.select2').select2();
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends '_base_list.html' %}
{% load i18n %}
{% load common_tags %}
{% block table_search %}
{% endblock %}
......
{% extends '_base_list.html' %}
{% load i18n %}
{% load static %}
{% load common_tags %}
{% block content_left_head %}
<link href="{% static "css/plugins/footable/footable.core.css" %}" rel="stylesheet">
<link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet">
......
{% extends 'base.html' %}
{% load common_tags %}
{% load static %}
{% load i18n %}
......
{% extends '_base_list.html' %}
{% load i18n %}
{% load static %}
{% load common_tags %}
{% block content_left_head %}
<link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet">
<style>
......
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -193,4 +191,4 @@
$('.select2').select2();
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -212,4 +210,4 @@
$('.select2').select2();
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends '_base_list.html' %}
{% load i18n %}
{% load common_tags %}
{% block content_left_head %}
<a href="{% url 'perms:asset-permission-create' %}" class="btn btn-sm btn-primary "> {% trans "Create permission" %} </a>
{% endblock %}
......
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -193,4 +191,4 @@
$('.select2').select2();
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% load common_tags %}
{% block custom_head_css_js %}
<link href="{% static "css/plugins/dataTables/dataTables.min.css" %}" rel="stylesheet">
<link href="{% static "css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" %}" rel="stylesheet">
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import os
from collections import OrderedDict
from django.conf import settings
from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import AbstractUser
from django.core import signing
from django.conf import settings
from django.db import models, IntegrityError
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from django.shortcuts import reverse
from common.utils import signer, date_expired_default
from . import UserGroup
from common.utils import signer, date_expired_default
__all__ = ['User']
......@@ -156,6 +157,17 @@ class User(AbstractUser):
return True
return False
def avatar_url(self):
if self.avatar:
return self.avatar.url
else:
default_dir = os.path.join(settings.MEDIA_ROOT, 'avatar', 'default')
if os.path.isdir(default_dir):
default_avatar_list = os.listdir(default_dir)
default_avatar = default_avatar_list[len(self.username) % len(default_avatar_list)]
return os.path.join(settings.MEDIA_URL, 'avatar', 'default', default_avatar)
return 'https://www.gravatar.com/avatar/c6812ab450230979465d7bf288eadce2a?s=120&d=identicon'
def generate_reset_token(self):
return signer.sign_t({'reset': self.id, 'email': self.email}, expires_in=3600)
......
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %}
{% load static %}
{% load i18n %}
......@@ -182,4 +180,4 @@
});
})
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -55,7 +53,7 @@
<tbody>
<tr class="no-borders-tr">
<td colspan="2">
<img src="{{ user|user_avatar_url }}" class="img-circle" width="64" height="64">
<img src="{{ user.avatar_url }}" class="img-circle" width="64" height="64">
</td>
</tr>
<tr>
......
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %}
{% load static %}
{% load i18n %}
......@@ -155,4 +153,4 @@
jumpserver.initDataTable(options2);
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %}
{% load static %}
{% load i18n %}
......@@ -180,4 +178,4 @@
console.log('click excel')
})
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %}
{% load static %}
{% load i18n %}
......@@ -155,4 +153,4 @@
jumpserver.initDataTable(options2);
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
......@@ -11,7 +9,7 @@
{% block content %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-4">
<div class="col-sm-6">
<div class="ibox float-e-margins">
<div class="ibox-title">
<span class="label label-primary"><b>{{ user.name }}</b></span>
......@@ -84,7 +82,7 @@
<td>
{% for group in asset_groups %}
<span class="simple-tag with-link">
<a href="#">{{ group.name }}</a>
<a href="{% url 'assets:asset-group-detail' group.id %}">{{ group.name }}</a>
</span>
{% endfor %}
</td>
......@@ -94,7 +92,7 @@
<td>
{% for perm in permissions %}
<span class="simple-tag with-link">
<a href="#">{{ perm.name }}</a>
<a href="{% url 'perms:asset-permission-detail' perm.id %}">{{ perm.name }}</a>
</span>
{% endfor %}
</td>
......@@ -105,8 +103,7 @@
</div>
</div>
</div>
<div class="col-sm-4"></div>
<div class="col-sm-4"></div>
<div class="col-sm-6"></div>
</div>
</div>
{% endblock %}
......
# ~*~ coding: utf-8 ~*~
import os
import urllib
import hashlib
from django import template
from django.utils import timezone
from django.conf import settings
register = template.Library()
@register.filter
def join_queryset_attr(queryset, attr, delimiter=', '):
return delimiter.join([getattr(obj, attr, '') for obj in queryset])
@register.filter
def is_expired(datetime):
if datetime > timezone.now():
return False
else:
return True
@register.filter
def user_avatar_url(user):
if user.avatar:
return user.avatar.url
else:
default_dir = os.path.join(settings.MEDIA_ROOT, 'avatar', 'default')
if os.path.isdir(default_dir):
default_avatar_list = os.listdir(default_dir)
default_avatar = default_avatar_list[len(user.username) % len(default_avatar_list)]
return os.path.join(settings.MEDIA_URL, 'avatar', 'default', default_avatar)
return 'https://www.gravatar.com/avatar/c6812ab450230979465d7bf288eadce2a?s=120&d=identicon'
......@@ -324,8 +324,5 @@ class UserProfileView(LoginRequiredMixin, TemplateView):
'asset_groups': asset_groups,
'permissions': permissions
}
print assets
print asset_groups
print permissions
kwargs.update(context)
return super(UserProfileView, self).get_context_data(**kwargs)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment