remove unused templatetags: users_tags and common_tags

parent f3647ea4
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -396,4 +394,4 @@ $(document).ready(function () { ...@@ -396,4 +394,4 @@ $(document).ready(function () {
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -395,4 +393,4 @@ $(document).ready(function () { ...@@ -395,4 +393,4 @@ $(document).ready(function () {
}) })
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends '_base_list.html' %} {% extends '_base_list.html' %}
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% load common_tags %}
{% block custom_head_css_js %} {% block custom_head_css_js %}
<link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet"> <link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script> <script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
...@@ -325,4 +324,4 @@ $(document).ready(function(){ ...@@ -325,4 +324,4 @@ $(document).ready(function(){
$('#asset_bulk_update_modal').modal('hide'); $('#asset_bulk_update_modal').modal('hide');
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -276,4 +274,4 @@ $(document).ready(function () { ...@@ -276,4 +274,4 @@ $(document).ready(function () {
deleteTagAssets($this, name, the_url, data); deleteTagAssets($this, name, the_url, data);
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends '_base_list.html' %} {% extends '_base_list.html' %}
{% load i18n static %} {% load i18n static %}
{#{% load common_tags %}#}
{% block custom_head_css_js %} {% block custom_head_css_js %}
<link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet"> <link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script> <script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
...@@ -123,4 +122,4 @@ $(document).ready(function () { ...@@ -123,4 +122,4 @@ $(document).ready(function () {
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -365,4 +363,4 @@ $(document).ready(function () { ...@@ -365,4 +363,4 @@ $(document).ready(function () {
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -156,4 +154,4 @@ $(document).ready(function () { ...@@ -156,4 +154,4 @@ $(document).ready(function () {
idcDelete(name, the_url); idcDelete(name, the_url);
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -370,4 +368,4 @@ $(document).ready(function () { ...@@ -370,4 +368,4 @@ $(document).ready(function () {
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -133,4 +131,4 @@ ...@@ -133,4 +131,4 @@
$('.select2').select2(); $('.select2').select2();
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -184,4 +182,4 @@ ...@@ -184,4 +182,4 @@
$('.select2').select2(); $('.select2').select2();
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends '_base_list.html' %} {% extends '_base_list.html' %}
{% load i18n %} {% load i18n %}
{% load common_tags %}
{% block table_search %} {% block table_search %}
{% endblock %} {% endblock %}
......
{% extends '_base_list.html' %} {% extends '_base_list.html' %}
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% load common_tags %}
{% block content_left_head %} {% block content_left_head %}
<link href="{% static "css/plugins/footable/footable.core.css" %}" rel="stylesheet"> <link href="{% static "css/plugins/footable/footable.core.css" %}" rel="stylesheet">
<link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet"> <link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet">
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
......
{% extends '_base_list.html' %} {% extends '_base_list.html' %}
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% load common_tags %}
{% block content_left_head %} {% block content_left_head %}
<link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet"> <link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet">
<style> <style>
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -193,4 +191,4 @@ ...@@ -193,4 +191,4 @@
$('.select2').select2(); $('.select2').select2();
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -212,4 +210,4 @@ ...@@ -212,4 +210,4 @@
$('.select2').select2(); $('.select2').select2();
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends '_base_list.html' %} {% extends '_base_list.html' %}
{% load i18n %} {% load i18n %}
{% load common_tags %}
{% block content_left_head %} {% block content_left_head %}
<a href="{% url 'perms:asset-permission-create' %}" class="btn btn-sm btn-primary "> {% trans "Create permission" %} </a> <a href="{% url 'perms:asset-permission-create' %}" class="btn btn-sm btn-primary "> {% trans "Create permission" %} </a>
{% endblock %} {% endblock %}
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -193,4 +191,4 @@ ...@@ -193,4 +191,4 @@
$('.select2').select2(); $('.select2').select2();
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% load common_tags %}
{% block custom_head_css_js %} {% block custom_head_css_js %}
<link href="{% static "css/plugins/dataTables/dataTables.min.css" %}" rel="stylesheet"> <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"> <link href="{% static "css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" %}" rel="stylesheet">
......
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
import os
from collections import OrderedDict from collections import OrderedDict
from django.conf import settings
from django.contrib.auth.hashers import make_password from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
from django.core import signing from django.core import signing
from django.conf import settings from django.db import models
from django.db import models, IntegrityError
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils import timezone from django.utils import timezone
from django.shortcuts import reverse from django.shortcuts import reverse
from common.utils import signer, date_expired_default
from . import UserGroup from . import UserGroup
from common.utils import signer, date_expired_default
__all__ = ['User'] __all__ = ['User']
...@@ -156,6 +157,17 @@ class User(AbstractUser): ...@@ -156,6 +157,17 @@ class User(AbstractUser):
return True return True
return False 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): def generate_reset_token(self):
return signer.sign_t({'reset': self.id, 'email': self.email}, expires_in=3600) return signer.sign_t({'reset': self.id, 'email': self.email}, expires_in=3600)
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %} {% load bootstrap %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -182,4 +180,4 @@ ...@@ -182,4 +180,4 @@
}); });
}) })
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -55,7 +53,7 @@ ...@@ -55,7 +53,7 @@
<tbody> <tbody>
<tr class="no-borders-tr"> <tr class="no-borders-tr">
<td colspan="2"> <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> </td>
</tr> </tr>
<tr> <tr>
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %} {% load bootstrap %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -155,4 +153,4 @@ ...@@ -155,4 +153,4 @@
jumpserver.initDataTable(options2); jumpserver.initDataTable(options2);
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %} {% load bootstrap %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -180,4 +178,4 @@ ...@@ -180,4 +178,4 @@
console.log('click excel') console.log('click excel')
}) })
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %} {% load bootstrap %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -155,4 +153,4 @@ ...@@ -155,4 +153,4 @@
jumpserver.initDataTable(options2); jumpserver.initDataTable(options2);
}); });
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
...@@ -11,7 +9,7 @@ ...@@ -11,7 +9,7 @@
{% block content %} {% block content %}
<div class="wrapper wrapper-content animated fadeInRight"> <div class="wrapper wrapper-content animated fadeInRight">
<div class="row"> <div class="row">
<div class="col-sm-4"> <div class="col-sm-6">
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-title"> <div class="ibox-title">
<span class="label label-primary"><b>{{ user.name }}</b></span> <span class="label label-primary"><b>{{ user.name }}</b></span>
...@@ -84,7 +82,7 @@ ...@@ -84,7 +82,7 @@
<td> <td>
{% for group in asset_groups %} {% for group in asset_groups %}
<span class="simple-tag with-link"> <span class="simple-tag with-link">
<a href="#">{{ group.name }}</a> <a href="{% url 'assets:asset-group-detail' group.id %}">{{ group.name }}</a>
</span> </span>
{% endfor %} {% endfor %}
</td> </td>
...@@ -94,7 +92,7 @@ ...@@ -94,7 +92,7 @@
<td> <td>
{% for perm in permissions %} {% for perm in permissions %}
<span class="simple-tag with-link"> <span class="simple-tag with-link">
<a href="#">{{ perm.name }}</a> <a href="{% url 'perms:asset-permission-detail' perm.id %}">{{ perm.name }}</a>
</span> </span>
{% endfor %} {% endfor %}
</td> </td>
...@@ -105,8 +103,7 @@ ...@@ -105,8 +103,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-sm-4"></div> <div class="col-sm-6"></div>
<div class="col-sm-4"></div>
</div> </div>
</div> </div>
{% endblock %} {% 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): ...@@ -324,8 +324,5 @@ class UserProfileView(LoginRequiredMixin, TemplateView):
'asset_groups': asset_groups, 'asset_groups': asset_groups,
'permissions': permissions 'permissions': permissions
} }
print assets
print asset_groups
print permissions
kwargs.update(context) kwargs.update(context)
return super(UserProfileView, self).get_context_data(**kwargs) 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