diff --git a/README.md b/README.md index e0b6879..5aa803b 100644 --- a/README.md +++ b/README.md @@ -76,3 +76,19 @@ python manage.py generate_reviews ``` ---------------------------------------- + +# Tooltip examples + +``` +
+``` + +``` +
+
+``` + +---------------------------------------- diff --git a/assets/index.js b/assets/index.js index 074e797..3b5bcd1 100644 --- a/assets/index.js +++ b/assets/index.js @@ -2,8 +2,9 @@ $('.datepicker').datepicker() - - +$('[data-tooltip]').tooltip({ + container: 'body', // Remove unwanted side-effects +}) diff --git a/common/admin.py b/common/admin.py index 01a9179..9511478 100644 --- a/common/admin.py +++ b/common/admin.py @@ -1,13 +1,20 @@ from django.contrib import admin from mptt.admin import MPTTModelAdmin -from .models import Location, MainPage, Settings, PrintOrder, PrintDocuments +from .models import Location, MainPage, Settings, PrintOrder, PrintDocuments, Tooltip + class LocationAdmin(MPTTModelAdmin): readonly_fields = ('pk', 'lft', 'rght', 'tree_id', 'level') + +class TooltipAdmin(admin.ModelAdmin): + readonly_fields = ('pk',) + list_display = ('name', 'pk', 'text') + admin.site.register(Location, LocationAdmin) admin.site.register(MainPage) -admin.site.register(Settings) -admin.site.register(PrintOrder) admin.site.register(PrintDocuments) +admin.site.register(PrintOrder) +admin.site.register(Settings) +admin.site.register(Tooltip, TooltipAdmin) diff --git a/common/migrations/0006_tooltip.py b/common/migrations/0006_tooltip.py new file mode 100644 index 0000000..1b657bd --- /dev/null +++ b/common/migrations/0006_tooltip.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-29 15:37 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0005_settings_accountant_send_email'), + ] + + operations = [ + migrations.CreateModel( + name='Tooltip', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255, unique=True)), + ('text', models.TextField()), + ], + options={ + 'verbose_name_plural': 'Подсказки', + 'verbose_name': 'Подсказка', + }, + ), + ] diff --git a/common/migrations/0007_tooltip_example.py b/common/migrations/0007_tooltip_example.py new file mode 100644 index 0000000..743a9d5 --- /dev/null +++ b/common/migrations/0007_tooltip_example.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-29 16:19 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0006_tooltip'), + ] + + operations = [ + migrations.AddField( + model_name='tooltip', + name='example', + field=models.TextField(default=''), + preserve_default=False, + ), + ] diff --git a/common/migrations/0008_auto_20160829_1923.py b/common/migrations/0008_auto_20160829_1923.py new file mode 100644 index 0000000..c8dd7c7 --- /dev/null +++ b/common/migrations/0008_auto_20160829_1923.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-29 16:23 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0007_tooltip_example'), + ] + + operations = [ + migrations.AlterField( + model_name='tooltip', + name='example', + field=models.TextField(blank=True), + ), + migrations.AlterField( + model_name='tooltip', + name='text', + field=models.TextField(blank=True), + ), + ] diff --git a/common/models.py b/common/models.py index 61edfd9..ec771cf 100644 --- a/common/models.py +++ b/common/models.py @@ -84,3 +84,15 @@ class PrintDocuments(models.Model): verbose_name = 'Документы на распечатку' verbose_name_plural = 'Документы на распечатку' + +class Tooltip(models.Model): + name = models.CharField(max_length=255, unique=True) + text = models.TextField(blank=True) + example = models.TextField(blank=True) + + class Meta: + verbose_name = 'Подсказка' + verbose_name_plural = 'Подсказки' + + def __str__(self): + return self.name diff --git a/common/templatetags/common_tags.py b/common/templatetags/common_tags.py index 647feb0..b418eea 100644 --- a/common/templatetags/common_tags.py +++ b/common/templatetags/common_tags.py @@ -3,13 +3,11 @@ from pprint import pprint, pformat import os from archilance import util +from common.models import Tooltip register = template.Library() -# @register.inclusion_tag('templatetags/inspect.html', takes_context=True) -# def inspect(context, obj): -# return {'obj': pformat(obj.__dict__)} @register.simple_tag def morph_words(number, words): @@ -94,4 +92,12 @@ def decap(val): return val +@register.simple_tag +def tooltip(**kwargs): + tooltip = util.get_or_none(Tooltip, **kwargs) + + if tooltip: + return tooltip.text + + # import code; code.interact(local=dict(globals(), **locals())) diff --git a/projects/migrations/0018_auto_20160829_1837.py b/projects/migrations/0018_auto_20160829_1837.py new file mode 100644 index 0000000..cbc65ea --- /dev/null +++ b/projects/migrations/0018_auto_20160829_1837.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-29 15:37 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0017_arbitration'), + ] + + operations = [ + migrations.AlterField( + model_name='portfolio', + name='created', + field=models.DateTimeField(auto_created=True, auto_now_add=True), + ), + ] diff --git a/projects/templates/customer_project_create.html b/projects/templates/customer_project_create.html index 63e5e28..95e6024 100644 --- a/projects/templates/customer_project_create.html +++ b/projects/templates/customer_project_create.html @@ -24,12 +24,12 @@
{{ form.non_field_errors }}
{% endif %} -
+

Название заказа {{ form.name.errors.as_text }}

-
+

Подробно опишите задание {{ form.text.errors.as_text }}

@@ -53,7 +53,7 @@

Тип работы {{ form.work_type.errors.as_text }}

-
+
{% for id, text in form.work_type.field.choices %}
-
+
@@ -107,14 +107,14 @@
-
+
{{ form.currency }}
{{ form.term_type }}
-
+
@@ -179,7 +179,7 @@

- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro vel suscipit eaque quidem voluptate aperiam enim aut libero, excepturi architecto maxime, placeat maiores, odio itaque, ex consectetur dignissimos dicta officia + {% tooltip pk=11 as tooltip11 %}{{ tooltip11|linebreaksbr }}

@@ -192,7 +192,7 @@

Расширенный поиск

-
@@ -210,7 +210,7 @@
-
+
-
+
Местоположение {{ realty_form.location.errors.as_text }}
-
- -
- -
- -
- -
- +
+
+ +
+ +
+ +
+ +
+ +
-
+

Требуется допуск (СРО)

diff --git a/users/templates/contractor_office.html b/users/templates/contractor_office.html index 6e7b635..50730f7 100644 --- a/users/templates/contractor_office.html +++ b/users/templates/contractor_office.html @@ -17,7 +17,7 @@
- {% if contractor.team %} + {% if False and contractor.team %}