remove unused templatetags: users_tags and common_tags

pull/530/head
xiaokong1937@gmail.com 2017-01-26 20:24:50 +08:00
parent f3647ea46d
commit 8a5d0b2d92
33 changed files with 37 additions and 116 deletions

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,5 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,7 +1,6 @@
{% 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>

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,5 @@
{% 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>

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,5 @@
{% extends '_base_list.html' %} {% extends '_base_list.html' %}
{% load i18n %} {% load i18n %}
{% load common_tags %}
{% block table_search %} {% block table_search %}
{% endblock %} {% endblock %}

View File

@ -1,7 +1,6 @@
{% 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">

View File

@ -1,5 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,7 +1,6 @@
{% 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>

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,5 @@
{% 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 %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,5 @@
{% 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">

View File

@ -1,20 +1,21 @@
#!/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):
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)

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %} {% load bootstrap %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
@ -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>

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %} {% load bootstrap %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %} {% load bootstrap %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load bootstrap %} {% load bootstrap %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}

View File

@ -1,6 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
@ -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 @@
<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 @@
<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 @@
</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 %}

View File

@ -1,38 +0,0 @@
# ~*~ 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'

View File

@ -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)