Правки

Правки для PR-45
+ исправлено загрузка и  отображение Аватарки
remotes/origin/PR-58
booblegum 9 years ago
parent cb45ce94e2
commit 778282ea7f
  1. 111
      assets/js/build/user_profile_edit.js
  2. 42
      assets/js/src/seeds/avatar_upload.js
  3. 56
      assets/js/src/user.js
  4. 5
      assets/js/src/user_profile_edit.js
  5. 1
      assets/lib/proekton-components/sass/parts/_selected-container.sass
  6. 7
      users/models.py
  7. 12
      users/static/sass/customer-profile.sass
  8. 24
      users/templates/partials/inc-customer_profile-info.html
  9. 15
      users/templates/user_profile_edit.html
  10. 3
      webpack.config.js

@ -0,0 +1,111 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _avatar_upload = __webpack_require__(27);
$(function () {
(0, _avatar_upload.avatarUploadInit)();
});
/***/ },
/***/ 27:
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
// Live image avatar (single) upload ---------------------------------
var LIVE_IMAGE_UPLOAD_URL = '/common/live-image-upload/create/';
function avatarUploadInit() {
var $container = $('.-live-image-avatar-upload-container').first();
var $avatarImage = $container.find('.-avatar-image').first();
var $liveImageUpload = $container.find('.-live-image-upload').first();
var $liveImageId = $container.find('.-live-image-id').first();
var $liveImageDelete = $container.find('.-live-image-delete').first();
$avatarImage.attr('orig-src', $avatarImage.attr('src'));
$liveImageUpload.fileupload({
url: LIVE_IMAGE_UPLOAD_URL,
dataType: 'json',
done: function done($evt, data) {
var image = data.result;
$avatarImage.attr('src', image.thumbnailUrl);
$liveImageId.val(image.id);
$liveImageDelete.data('url', image.deleteUrl);
$liveImageDelete.css('display', 'block');
}
});
$liveImageDelete.on('click', function ($evt) {
var $that = $(this);
$.post($that.data('url')).then(function (res) {
if (res.status == 'success') {
$avatarImage.attr('src', $avatarImage.attr('orig-src') || STUB_IMAGE_URL);
$liveImageId.val('');
$that.css('display', 'none');
}
});
});
}
exports.avatarUploadInit = avatarUploadInit;
/***/ }
/******/ });

@ -0,0 +1,42 @@
// Live image avatar (single) upload ---------------------------------
var LIVE_IMAGE_UPLOAD_URL = '/common/live-image-upload/create/';
function avatarUploadInit() {
var $container = $('.-live-image-avatar-upload-container').first();
var $avatarImage = $container.find('.-avatar-image').first();
var $liveImageUpload = $container.find('.-live-image-upload').first();
var $liveImageId = $container.find('.-live-image-id').first();
var $liveImageDelete = $container.find('.-live-image-delete').first();
$avatarImage.attr('orig-src', $avatarImage.attr('src'));
$liveImageUpload.fileupload({
url: LIVE_IMAGE_UPLOAD_URL,
dataType: 'json',
done: function($evt, data) {
var image = data.result;
$avatarImage.attr('src', image.thumbnailUrl);
$liveImageId.val(image.id);
$liveImageDelete.data('url', image.deleteUrl);
$liveImageDelete.css('display', 'block')
}
});
$liveImageDelete.on('click', function($evt) {
var $that = $(this);
$.post($that.data('url')).then(function(res) {
if (res.status == 'success') {
$avatarImage.attr('src', $avatarImage.attr('orig-src') || STUB_IMAGE_URL);
$liveImageId.val('');
$that.css('display', 'none')
}
})
})
}
export {avatarUploadInit}

@ -1,56 +0,0 @@
function onBind(target, name, descriptor) {
const method = descriptor.value;
descriptor.value = function (...args) {
let binds = [];
args = Array.from(args);
for (let arg of args.slice()) {
if (typeof arg === 'object') {
binds.push(arg);
args.splice(args.indexOf(arg), 1);
}
}
method.apply(this, args);
for (let bind of binds) {
bind.func.bind(this)();
}
return this;
}
}
class Base {
constructor() {
this.attr1 = 'attr1';
console.log("Constructor")
}
@onBind
method1(a = 1, b = 2) {
console.log("this.attr1 = ", this.attr1);
console.log("a = ", a, "b = ", b);
}
on(methodName, func) {
this[methodName] = this[methodName].bind(this, {func});
}
}
let b = new Base();
b.on("method1", () => console.log("Another message..."));
b.on("method1", function () {
console.log("bind this.attr1 =", this.attr1);
});
b.method1("one", 2);
b.method1("bbb");
if (NODE_ENV == 'dev') {
console.log("Dev mode message")
}
function a({a=2, b=a+4}) {
}

@ -0,0 +1,5 @@
import {avatarUploadInit} from './seeds/avatar_upload'
$(function () {
avatarUploadInit();
});

@ -23,6 +23,7 @@
.header .header
font-size: 7pt font-size: 7pt
color: #676363 color: #676363
display: block
.name .name
font-size: 11pt font-size: 11pt
display: inline-block display: inline-block

@ -171,13 +171,13 @@ class User(AbstractBaseUser, PermissionsMixin):
try: try:
return self.location.parent.parent.name return self.location.parent.parent.name
except AttributeError: except AttributeError:
return 'None' return 'Не задан'
def city(self): def city(self):
try: try:
return self.location.name return self.location.name
except AttributeError: except AttributeError:
return 'None' return "Не задан"
# @property # @property
# def is_staff(self): # def is_staff(self):
# return self.is_superuser # return self.is_superuser
@ -189,7 +189,8 @@ class User(AbstractBaseUser, PermissionsMixin):
return self.email return self.email
def get_full_name(self): def get_full_name(self):
full_name = self.first_name + ' ' + self.last_name + ' ' + self.patronym full_name = '{last_name} {first_name} {patronym}'.format(**self.__dict__)
# full_name = self.first_name + ' ' + self.last_name + ' ' + self.patronym
return full_name or self.username return full_name or self.username
def get_profile_image(self): def get_profile_image(self):

@ -1,14 +1,8 @@
@import "base/variavles" @import "base/variavles"
@import "modules/mods" @import "modules/mods"
//.avatarInset .avatar
// //width: 100% border: 15px solid #F1F1F1
// height: 224px
// img
// width: 100%
// height: 100%
// //padding: 10%
// background-color: #e4e4e4
.count .count
display: inline-block display: inline-block
@ -44,7 +38,6 @@
font-size: 16pt font-size: 16pt
line-height: 100% line-height: 100%
.border.add_line:before .border.add_line:before
content: '' content: ''
position: relative position: relative
@ -61,6 +54,7 @@
.nav-tabs a .nav-tabs a
color: #0b0b0b color: #0b0b0b
table.ratings table.ratings
font-size: 14pt font-size: 14pt
td td

@ -4,20 +4,18 @@
{% load user_tags %} {% load user_tags %}
<div class="row"> <div class="row">
<div class="col-lg-3"> <div class="col-lg-3">
<div class="avatar new-mar"> <div class="avatar">
<div class="avatarInset">
{% if customer.avatar %} {% if customer.avatar %}
{% thumbnail customer.avatar "235x224" crop="center" as im %} {% thumbnail customer.avatar "220x220" crop="center" as im %}
<img src="{{ im.url }}" alt="profile-image"> <img src="{{ im.url }}" alt="profile-image">
{% endthumbnail %} {% endthumbnail %}
{% else %} {% else %}
<img src="{% static 'img/profile.jpg' %}" alt="profile-image"> <img src="{% static 'img/profile.jpg' %}" width="220" height="220" alt="profile-image">
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div>
<div class="col-lg-9"> <div class="col-lg-9">
<div class="row mod-row-eq-height" style="padding-bottom: 40px"> <div class="row mod-row-eq-height" style="padding-bottom: 30px">
<div class="col-lg-5"> <div class="col-lg-5">
<span class="user_name">{{ customer.get_full_name }} <br>[{{ customer.username }}]</span> <span class="user_name">{{ customer.get_full_name }} <br>[{{ customer.username }}]</span>
<table style="margin-top: 10px; margin-bottom: 10px"> <table style="margin-top: 10px; margin-bottom: 10px">
@ -36,7 +34,7 @@
</table> </table>
{% if request.user == customer %} {% if request.user == customer %}
<a href="{% url 'users:user-profile-edit' pk=pk %}" class="btn btn-simple mod-align-center-inline" <a href="{% url 'users:user-profile-edit' pk=pk %}" class="btn btn-simple mod-align-center-inline"
style="padding: px 20px; font-size: 12pt"> style="padding: 8px 20px; font-size: 12pt">
<span type="submit" class="icon-edit"> </span> редактировать профиль <span type="submit" class="icon-edit"> </span> редактировать профиль
</a> </a>
{% endif %} {% endif %}
@ -79,22 +77,26 @@
<ul class="nav nav-tabs nav-justified"> <ul class="nav nav-tabs nav-justified">
<li class="active"> <li class="active">
<a data-toggle="tab" href="#objects"> <a data-toggle="tab" href="#objects">
<div class="mod-align-center-inline"> Объекты <span class="count">{{ objects.count }}</span></div> <div class="mod-align-center-inline"> Объекты <span
class="count">{{ objects.count }}</span></div>
</a> </a>
</li> </li>
<li> <li>
<a data-toggle="tab" href="#open_projects"> <a data-toggle="tab" href="#open_projects">
<div class="mod-align-center-inline"> Открытые заказы <span class="count">{{ open_projects.count }}</span></div> <div class="mod-align-center-inline"> Открытые заказы <span
class="count">{{ open_projects.count }}</span></div>
</a> </a>
</li> </li>
<li> <li>
<a data-toggle="tab" href="#in_work_projects"> <a data-toggle="tab" href="#in_work_projects">
<div class="mod-align-center-inline"> Заказы в работе <span class="count">{{ projects_in_work.count }}</span></div> <div class="mod-align-center-inline"> Заказы в работе <span
class="count">{{ projects_in_work.count }}</span></div>
</a> </a>
</li> </li>
<li> <li>
<a data-toggle="tab" href="#rewiews"> <a data-toggle="tab" href="#rewiews">
<div class="mod-align-center-inline"> Отзывы <span class="count">{{ reviews.count }}</span></div> <div class="mod-align-center-inline"> Отзывы <span
class="count">{{ reviews.count }}</span></div>
</a> </a>
</li> </li>
</ul> </ul>

@ -37,12 +37,16 @@
<img src="{{ avatar.url }}" alt="profile-image" class="-avatar-image"> <img src="{{ avatar.url }}" alt="profile-image" class="-avatar-image">
{% endthumbnail %} {% endthumbnail %}
{% else %} {% else %}
<img src="{% static 'img/profile.jpg' %}" alt="profile-image" <img src="{% static 'img/profile.jpg' %}" width="208" height="208" alt="profile-image" class="-avatar-image">
class="-avatar-image"> {# {% with "/static/img/profile.jpg" as path %}#}
{# {% thumbnail path "100x100" crop="center" as im %}#}
{# <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt="profile-image" class="-avatar-image">#}
{# {% endthumbnail %}#}
{# {% endwith %}#}
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div style="margin-top: 15px"> <div style="margin-top: 15px; margin-bottom: 15px">
<div class="upload-new"> <div class="upload-new">
{# <div class="upload2 up-l1">#} {# <div class="upload2 up-l1">#}
<input type="file" name="image" class="-live-image-upload"> <input type="file" name="image" class="-live-image-upload">
@ -318,6 +322,11 @@
{{ block.super }} {{ block.super }}
<script src='{% static "lib/proekton-components/js/build/init_user_profile.js" %}'></script> <script src='{% static "lib/proekton-components/js/build/init_user_profile.js" %}'></script>
<script src='{% static "projects-filter.js" %}'></script> <script src='{% static "projects-filter.js" %}'></script>
<script src='{% static "lib/jquery.fileupload/js/vendor/jquery.ui.widget.js" %}'></script>
<script src='{% static "lib/jquery.fileupload/js/jquery.iframe-transport.js" %}'></script>
<script src='{% static "lib/jquery.fileupload/js/jquery.fileupload.js" %}'></script>
<script src='{% static "lib/jquery.fileupload/js/jquery.fileupload-process.js" %}'></script>
<script src='{% static "js/build/user_profile_edit.js" %}'></script>
<script src='{% static "js/jquery.mask.min.js" %}'></script> <script src='{% static "js/jquery.mask.min.js" %}'></script>
<script> <script>
$(function () { $(function () {

@ -17,7 +17,8 @@ module.exports = {
//home //home
home_page: "./assets/js/src/home_page.js", home_page: "./assets/js/src/home_page.js",
//profile //profile
customer_profile: "./assets/js/src/customer_profile.js" customer_profile: "./assets/js/src/customer_profile.js",
user_profile_edit: "./assets/js/src/user_profile_edit.js"
}, },

Loading…
Cancel
Save