remotes/origin/setup
ArturBaybulatov 10 years ago
parent fd862136b5
commit 6a12f2dd62
  1. 7
      archilance/management/commands/generate_projects.py
  2. 2
      archilance/management/commands/generate_users.py
  3. 19
      archilance/management/commands/tmp.py
  4. 20
      projects/models.py
  5. 6
      reviews/models.py
  6. 1
      users/forms.py
  7. 56
      users/models.py
  8. 39
      users/templates/contractor_filter.html
  9. 53
      users/views.py
  10. 16
      work_sell/models.py

@ -74,7 +74,12 @@ class Command(BaseCommand):
project.save()
Order.objects.create(project=project)
Order.objects.create(
project=project,
contractor=_.sample((None, User.contractor_objects.order_by('?').first())),
secure=_.sample((True, False)),
status=_.sample((True, False)),
)
return project

@ -6,6 +6,7 @@ import pydash as _; _.map = _.map_; _.filter = _.filter_
import random
from archilance import util
from common.models import Location
from specializations.models import Specialization
from users.models import User, GENDERS
@ -95,5 +96,6 @@ class Command(BaseCommand):
user.set_password('123')
user.groups.add(customer_group if user.pk % 2 == 0 else contractor_group)
user.contractor_specializations = Specialization.objects.order_by('?')[:_.random(1, 5)]
user.location = Location.objects.root_nodes()[0].get_descendants().order_by('?').first()
user.save()

@ -0,0 +1,19 @@
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.core.management import BaseCommand
from django.utils import timezone
import pydash as _; _.map = _.map_; _.filter = _.filter_
import random
from archilance import util
from common.models import Location
from projects.models import Project, Order, CURRENCIES, TERMS, Specialization, Realty
from users.models import User
class Command(BaseCommand):
def handle(self, *args, **options):
for user in User.objects.all():
user.location = Location.objects.root_nodes()[0].get_descendants().order_by('?').first()
user.save()

@ -80,16 +80,16 @@ class Project(models.Model):
cro = models.BooleanField(default=False)
currency = models.CharField(max_length=20, default='rur', choices=CURRENCIES)
customer = models.ForeignKey(User, related_name='projects')
deal_type = models.CharField(max_length=20, default='secure_deal', choices=DEAL_TYPES)
name = models.CharField(max_length=255)
price_and_term_required = models.BooleanField(default=False)
realty = models.ForeignKey(Realty, blank=True, null=True, related_name='projects')
deal_type = models.CharField(max_length=20, default='secure_deal', choices=DEAL_TYPES)
specialization = TreeForeignKey(Specialization, related_name='projects')
state = models.CharField(default='active', max_length=20, choices=STATES)
term = models.IntegerField(default=0)
term_type = models.CharField(max_length=20, choices=TERMS, default='hour')
text = models.TextField(blank=True)
work_type = models.IntegerField(default=1, choices=WORK_TYPES)
state = models.CharField(default='active', max_length=20, choices=STATES)
def __str__(self):
return self.name
@ -116,13 +116,13 @@ class ProjectFile(models.Model):
class Answer(models.Model):
budget = models.DecimalField(max_digits=10, decimal_places=0)
currency = models.CharField(max_length=5, choices=CURRENCIES, default='rur')
contractor = models.ForeignKey(User, related_name='answers')
created = models.DateTimeField(default=timezone.now)
currency = models.CharField(max_length=5, choices=CURRENCIES, default='rur')
project = models.ForeignKey(Project, related_name='answers')
term = models.IntegerField(default=0)
term_type = models.CharField(max_length=10, choices=TERMS, default='hour')
text = models.TextField()
contractor = models.ForeignKey(User, related_name='answers')
def __str__(self):
return self.text
@ -179,18 +179,18 @@ class Candidate(models.Model):
class Portfolio(models.Model):
description = models.TextField()
name = models.CharField(max_length=255)
budget = models.DecimalField(max_digits=10, decimal_places=0, default=0, null=True, blank=True)
building_classification = models.ForeignKey(BuildingClassfication, related_name='portfolios',null=True, blank=True)
construction_type = models.ForeignKey(ConstructionType, related_name='portfolios',null=True, blank=True)
currency = models.CharField(max_length=20, default='rur', choices=CURRENCIES, null=True, blank=True)
description = models.TextField()
location = TreeForeignKey('common.Location', related_name='portfolios', null=True, blank=True)
name = models.CharField(max_length=255)
specialization = TreeForeignKey(Specialization, related_name='portfolios',null=True, blank=True)
term = models.IntegerField(default=0,null=True, blank=True)
term_type = models.CharField(max_length=20, choices=TERMS, default='hour',null=True, blank=True)
building_classification = models.ForeignKey(BuildingClassfication, related_name='portfolios',null=True, blank=True)
construction_type = models.ForeignKey(ConstructionType, related_name='portfolios',null=True, blank=True)
location = TreeForeignKey('common.Location', related_name='portfolios', null=True, blank=True)
worksell = models.BooleanField(default=False)
user = models.ForeignKey(User, related_name='portfolios')
worksell = models.BooleanField(default=False)
def __str__(self):
return self.name

@ -2,11 +2,11 @@ from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
class Review(models.Model):
text = models.TextField()
is_secured = models.BooleanField(default=False)
project = models.ForeignKey("projects.Project", related_name='reviews')
user = models.ForeignKey("users.User", related_name='reviews')
stars = models.IntegerField(validators=[MinValueValidator(1), MaxValueValidator(5)])
is_secured = models.BooleanField(default=False)
text = models.TextField()
user = models.ForeignKey("users.User", related_name='reviews')
def __str__(self):
return self.pk

@ -98,6 +98,7 @@ class ContractorFinancicalInfoForm(ModelForm):
class Meta:
model = ContractorFinancialInfo
fields = (
'fio',
'date_of_birth',

@ -55,20 +55,20 @@ class ContractorFinancialInfo(models.Model):
('legal_entity', 'ИП и юридическое лицо'),
)
fio = models.CharField(max_length=255)
credit_card_number = models.CharField(max_length=50)
date_of_birth = models.DateTimeField()
phone = models.CharField(max_length=30)
residency = models.CharField(max_length=50, choices=RESIDENCIES)
fio = models.CharField(max_length=255)
inn = models.CharField(max_length=100)
legal_status = models.CharField(max_length=30, choices=LEGAL_STATUSES)
passport_series = models.CharField(max_length=6)
passport_issue_date = models.DateTimeField()
passport_issued_by = models.CharField(max_length=255)
passport_number = models.CharField(max_length=10)
passport_scan = models.ImageField(upload_to='users/contractors/')
passport_series = models.CharField(max_length=6)
phone = models.CharField(max_length=30)
residency = models.CharField(max_length=50, choices=RESIDENCIES)
subdivision_code = models.CharField(max_length=10)
passport_issued_by = models.CharField(max_length=255)
passport_issue_date = models.DateTimeField()
inn = models.CharField(max_length=100)
yandex_money = models.CharField(max_length=50)
credit_card_number = models.CharField(max_length=50)
passport_scan = models.ImageField(upload_to='users/contractors/')
def __str__(self):
return self.fio
@ -78,8 +78,8 @@ class ContractorFinancialInfo(models.Model):
verbose_name_plural = 'Финансовая информация'
class ContractorResume(models.Model):
text = models.TextField()
resume_file = models.FileField(upload_to='users/resume/files/')
text = models.TextField()
def __str__(self):
return self.text
@ -96,11 +96,11 @@ RESUME_TYPE_FILES = (
class ContractorResumeFiles(models.Model):
description = models.TextField(blank=True)
img = models.ImageField(upload_to='users/resume/images/')
resume = models.ForeignKey(ContractorResume, related_name='resume_files')
title = models.CharField(max_length=255)
description = models.TextField(blank=True)
type = models.CharField(max_length=50, choices=RESUME_TYPE_FILES)
resume = models.ForeignKey(ContractorResume, related_name='resume_files')
def __str__(self):
return self.title
@ -116,27 +116,27 @@ class User(AbstractBaseUser, PermissionsMixin):
('busy', 'Занят'),
)
username = models.CharField(max_length=50, unique=True)
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
patronym = models.CharField(max_length=255, blank=True)
email = models.EmailField(max_length=255, unique=True, db_index=True)
is_active = models.BooleanField(default=True)
avatar = models.ImageField(upload_to='users/avatars/', blank=True)
contractor_financial_info = models.OneToOneField(ContractorFinancialInfo, related_name='contractor', blank=True, null=True)
contractor_resume = models.OneToOneField(ContractorResume, related_name='contractor', blank=True, null=True)
contractor_specializations = TreeManyToManyField(Specialization, related_name='contractors', blank=True)
contractor_status = models.CharField(default='free', max_length=20, choices=STATUSES)
created = models.DateTimeField(default=timezone.now)
cro = models.BooleanField(default=False)
date_joined = models.DateTimeField(default=timezone.now)
date_of_birth = models.DateTimeField(null=True, blank=True)
email = models.EmailField(max_length=255, unique=True, db_index=True)
first_name = models.CharField(max_length=255, blank=True)
gender = models.CharField(max_length=30, choices=GENDERS, blank=True)
is_active = models.BooleanField(default=True)
last_name = models.CharField(max_length=255, blank=True)
last_time_visit = models.DateTimeField(default=timezone.now)
contractor_specializations = TreeManyToManyField(Specialization, related_name='contractors', blank=True)
contractor_status = models.CharField(default='free', max_length=20, choices=STATUSES)
contractor_financial_info = models.OneToOneField(ContractorFinancialInfo, related_name='contractor',blank=True, null=True)
contractor_resume = models.OneToOneField(ContractorResume, related_name='contractor', blank=True, null=True)
location = TreeForeignKey('common.Location', related_name='users', null=True, blank=True)
patronym = models.CharField(max_length=255, blank=True)
phone = models.CharField(max_length=30, blank=True, null=True)
skype = models.CharField(max_length=100, blank=True)
gender = models.CharField(max_length=30, choices=GENDERS, blank=True)
cro = models.BooleanField(default=False)
username = models.CharField(max_length=50, unique=True)
website = models.CharField(max_length=255, blank=True)
date_of_birth = models.DateTimeField(null=True,blank=True)
avatar = models.ImageField(upload_to='users/avatars/', blank=True)
phone = models.CharField(max_length=30, blank=True, null=True)
@property
def is_staff(self):
@ -180,8 +180,8 @@ class User(AbstractBaseUser, PermissionsMixin):
class Team(models.Model):
name = models.CharField(max_length=255)
users = models.ManyToManyField(User, related_name ='teams', blank=True)
owner = models.OneToOneField(User, related_name='team', blank=True, null=True)
users = models.ManyToManyField(User, related_name ='teams', blank=True)
# groups = models.ManyToManyField(Group, related_name='teams', blank=True)
def __str__(self):

@ -9,7 +9,7 @@
<div class="container mainScore">
<div class="row">
<div class="col-lg-12">
<p class="titleScore">Поиск исполнителей</p>
<p class="titleScore">{% if display_msg %}{{ display_msg }}{% else %}Поиск исполнителей{% endif %}</p>
</div>
@ -78,7 +78,7 @@
<div class="resSearchF1">
@ -93,6 +93,28 @@
</div>
</div>
<div class="slideRes disTab activeSlide">
<div class="titleF1 disTab">
<div class="col-lg-3">Foooooooo</div>
</div>
<div class="polsF1 disTab">
<div class="col-lg-3">
<input type="hidden" class="-spec-select -spec-select-level-4" style="width: 100%">
</div>
</div>
</div>
</div>
</div>
@ -107,7 +129,7 @@
<div class="polsF1 disTab polsSearch">
<div class="col-lg-3">
<select class="selectpicker">
<option>Mustard</option>
<option>Сортировать по рейтингу</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
@ -206,6 +228,17 @@
</div>
{% if TEMPLATE_DEBUG %}
<div class="col-lg-12">
<pre><!--
-->Specializations: {{ contractor.contractor_specializations.all }}<br><!--
--><br><!--
-->Location: {{ contractor.location }}<br><!--
--></pre>
</div>
{% endif %}
<div class="gallMini disTab">
<div class="col-lg-3">
<a href="#" class="linkInsetCol">

@ -48,12 +48,12 @@ class ContractorFilterView(BaseMixin, View):
# keywords = form.cleaned_data.get('keywords')
# cro = form.cleaned_data.get('cro')
# work_type = form.cleaned_data.get('work_type')
# specialization = form.cleaned_data.get('specialization')
#
specialization = form.cleaned_data.get('specialization')
# building_classification = realty_form.cleaned_data.get('building_classification')
# construction_type = realty_form.cleaned_data.get('construction_type')
# location = realty_form.cleaned_data.get('location')
#
location = form.cleaned_data.get('location')
# if keywords:
# keywords = tuple(filter(None, re.split(r'\s|,|;', keywords)))
#
@ -64,25 +64,27 @@ class ContractorFilterView(BaseMixin, View):
#
# if work_type:
# projects = projects.filter(work_type=work_type)
#
# if specialization:
# projects = projects.filter(
# specialization__lft__gte=specialization.lft,
# specialization__rght__lte=specialization.rght,
# )
#
if specialization:
contractors = contractors.filter(
# specialization__lft__gte=specialization.lft,
# specialization__rght__lte=specialization.rght,
contractor_specializations=specialization,
)
# if building_classification:
# projects = projects.filter(realty__building_classification=building_classification)
#
# if construction_type:
# projects = projects.filter(realty__construction_type=construction_type)
#
# if location:
# projects = projects.filter(
# realty__location__lft__gte=location.lft,
# realty__location__rght__lte=location.rght,
# )
#
if location:
contractors = contractors.filter(
location__lft__gte=location.lft,
location__rght__lte=location.rght,
)
# order_by = form.cleaned_data.get('order_by')
# last_order_by = form.cleaned_data.get('last_order_by')
# reverse_order = form.cleaned_data.get('reverse_order')
@ -102,13 +104,13 @@ class ContractorFilterView(BaseMixin, View):
# 'last_order_by': last_order_by,
# 'reverse_order': reverse_order,
# })
#
# project_count = projects.count()
# display_msg = 'Найдено %s проектов' % project_count if project_count > 0 else 'Ничего не найдено'
messages.info(request, 'Форма норм') # Tmp
# import code; code.interact(local=dict(globals(), **locals()))
contr_count = contractors.count()
display_msg = 'Найдено %s исполнителей' % contr_count if contr_count > 0 else 'Ничего не найдено'
else:
# display_msg = 'Пожалуйста, введите корректные данные'
display_msg = 'Пожалуйста, введите корректные данные'
if form.errors:
messages.info(request, (
@ -139,7 +141,7 @@ class ContractorFilterView(BaseMixin, View):
'contractors': contractors,
'is_paginated': True,
'page_obj': contractors,
# 'display_msg': display_msg,
'display_msg': display_msg,
})
return render(request, self.template_name, context)
@ -268,3 +270,6 @@ class ContractorFinancialInfoEdit(CheckForUserMixin, View):
return redirect(reverse('users:contractor-financical', kwargs={'pk': request.user.pk}))
return render(request, self.template_name, {'form': form})
# import code; code.interact(local=dict(globals(), **locals()))

@ -10,19 +10,19 @@ from specializations.models import Specialization
class WorkSell(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True)
img = ImageField(upload_to='worksell/worksell', null=True, blank=True)
budget = models.DecimalField(max_digits=10, decimal_places=0, default=0, null=True, blank=True)
building_classification = models.ForeignKey(BuildingClassfication, related_name='worksells', null=True, blank=True)
construction_type = models.ForeignKey(ConstructionType, related_name='worksells', null=True, blank=True)
contractor = models.ForeignKey(User, related_name='work_sell')
created = models.DateTimeField(default=timezone.now, null=True, blank=True)
currency = models.CharField(max_length=20, default='rur', choices=CURRENCIES, null=True, blank=True)
description = models.TextField(blank=True)
img = ImageField(upload_to='worksell/worksell', null=True, blank=True)
location = TreeForeignKey('common.Location', related_name='worksells', null=True, blank=True)
name = models.CharField(max_length=255)
specialization = TreeForeignKey(Specialization, related_name='worksells', null=True, blank=True)
term = models.IntegerField(default=0, null=True, blank=True)
term_type = models.CharField(max_length=20, choices=TERMS, default='hour', null=True, blank=True)
contractor = models.ForeignKey(User, related_name='work_sell')
building_classification = models.ForeignKey(BuildingClassfication, related_name='worksells', null=True, blank=True)
construction_type = models.ForeignKey(ConstructionType, related_name='worksells', null=True, blank=True)
location = TreeForeignKey('common.Location', related_name='worksells', null=True, blank=True)
created = models.DateTimeField(default=timezone.now, null=True, blank=True)
def __str__(self):
return self.name

Loading…
Cancel
Save