From bbc7611646dd9e8fe0f643e61df274fa0dc6e5ad Mon Sep 17 00:00:00 2001 From: Nazar Kotyuk Date: Fri, 26 Dec 2014 07:53:43 +0200 Subject: [PATCH] User profile + user page --- accounts/user_catalog_urls.py | 16 + accounts/views.py | 17 + proj/urls.py | 3 +- templates/client/accounts/user.html | 101 +--- .../includes/accounts/current_user.html | 449 ++++++++++++++++++ .../client/includes/accounts/simple_user.html | 102 ++++ 6 files changed, 591 insertions(+), 97 deletions(-) create mode 100644 accounts/user_catalog_urls.py create mode 100644 templates/client/includes/accounts/current_user.html create mode 100644 templates/client/includes/accounts/simple_user.html diff --git a/accounts/user_catalog_urls.py b/accounts/user_catalog_urls.py new file mode 100644 index 00000000..6ebf7656 --- /dev/null +++ b/accounts/user_catalog_urls.py @@ -0,0 +1,16 @@ +from django.conf.urls import patterns, url +from django.contrib.auth.decorators import login_required +from views import SettingsView, ProfileView, CalendarView, UserView, UserExpositionsView, UserConferenceView, UserSeminarView + +urlpatterns = patterns('', + url(r'^(?P.*)/expositions/(?P\d+)/$', UserExpositionsView.as_view()), + url(r'^(?P.*)/expositions/$', UserExpositionsView.as_view()), + url(r'^(?P.*)/seminars/(?P\d+)/$', UserSeminarView.as_view()), + url(r'^(?P.*)/seminars/$', UserSeminarView.as_view()), + url(r'^(?P.*)/conferences/(?P\d+)/$', UserConferenceView.as_view()), + url(r'^(?P.*)/conferences/$', UserConferenceView.as_view()), + url(r'^(?P.*)/events/(?P\d+)/$', UserView.as_view()), + url(r'^(?P.*)/events/$', UserView.as_view()), + url(r'^(?P.*)/$', UserView.as_view()), +) + diff --git a/accounts/views.py b/accounts/views.py index be6d0a26..ab511004 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -168,6 +168,23 @@ class UserView(TemplateView): except ValueError: user = get_object_or_404(User, url=url) + if user == self.request.user: + profile = user.profile + profile_forms = { + 'avatar_form': AvatarForm(instance=profile), 'name_form': NameForm(instance=user), + 'home_form': HomeForm(instance=profile), 'work_form': WorkForm(instance=user), + 'about_company_form': AboutCompanyForm(instance=profile), 'phone_form': PhoneForm(instance=profile), + 'email_form': EmailForm(instance=user), 'web_page_form': WebPageForm(instance=profile), + 'social_form': SocialForm(instance=profile), 'about_form': AboutForm(instance=profile) + } + if not user.company: + company_form = {'company_form': CreateCompanyForm()} + context.update(company_form) + + context.update(profile_forms) + + + context['message_form'] = SendForm() context['member'] = user return context diff --git a/proj/urls.py b/proj/urls.py index 4ab41738..f20bfd65 100644 --- a/proj/urls.py +++ b/proj/urls.py @@ -81,7 +81,8 @@ urlpatterns += patterns('', -# url(r'^profile/change-password/', 'accounts.views.change_password'), + url(r'^', include('accounts.user_catalog_urls')), + ) """ diff --git a/templates/client/accounts/user.html b/templates/client/accounts/user.html index acd22f3e..3eaa18e9 100644 --- a/templates/client/accounts/user.html +++ b/templates/client/accounts/user.html @@ -12,103 +12,12 @@ {% block content_list %} -
-
- -
-
-
- {% if member.profile.country %} - {{ member.profile.country }}, {{ member.profile.city }} - {% endif %} -
-
{{ member.get_full_name }}
-
- -
{{ member.profile.position }} - {% if member.company %} - в “{{ member.company }}” - {% else %} - {{ member.profile.work }} - {% endif %} -
- -
- {{ member.profile.about_company|safe }} -
+ {% if request.user == member %} + {% include 'client/includes/accounts/current_user.html' %} + {% else %} + {% include 'client/includes/accounts/simple_user.html' %} + {% endif %} -
- -
-
- {% if user.is_authenticated %} - {% trans 'отправить сообщение' %} - {% endif %} - -
    - {% if member.profile.facebook %} -
  • Facebook
  • - {% endif %} - {% if member.profile.linkedin %} -
  • LinkedIn
  • - {% endif %} - {% if member.profile.vk %} -
  • В контакте
  • - {% endif %} - {% if member.profile.twitter %} -
  • Twitter
  • - {% endif %} -
-
- - -
- -
- -
-
{% trans 'О себе' %}:
- {{ member.profile.about|safe }} -
- -
- -
-
{% endblock %} {% if user.is_authenticated %} {% block popup %} diff --git a/templates/client/includes/accounts/current_user.html b/templates/client/includes/accounts/current_user.html new file mode 100644 index 00000000..bea19dcf --- /dev/null +++ b/templates/client/includes/accounts/current_user.html @@ -0,0 +1,449 @@ +{% load static %} +{% load i18n %} +{% load template_filters %} + + +
+
+ + {# avatar #} + + {# END avatar #} +
+
+ {# country and city #} +
+ {% if home_form.instance.country %} + + {% else %} + + {% endif %} + {{ home_form.instance.country }} + + + {% if home_form.instance.city %} + + {% else %} + + {% endif %} + , {{ home_form.instance.city }} + + +
+ {% trans 'редактировать' %} +
+
{% csrf_token %} +
+ +
+ +
+ {{ home_form.country }} + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ {% trans 'закрыть' %} +
+
+
+ {# END country and city #} + + {# name #} +
+ {{ name_form.get_full_name }} +
+ {% trans 'редактировать' %} +
+
{% csrf_token %} + +
+ +
+ +
+ {{ name_form.first_name }} +
+
+
+ +
+ {{ name_form.last_name }} +
+
+ +
+ +
+ +
+
+ + {% trans 'закрыть' %} +
+
+
+ {# END name #} +
+ + {# position #} +
+

+ {{ work_form.position.value }} + {% if work_form.work.value %} + {% trans 'в' %} {{ work_form.work.value }} + {% endif %} +

+ +
+ {% trans 'редактировать' %} +
+
{% csrf_token %} + +
+ +
+ +
+ {{ work_form.position }} +
+
+ +
+ +
+ {{ work_form.work }} +
+
+ +
+ +
+ +
+
+ + {% trans 'закрыть' %} +
+
+
+ {# END position #} + + + {# description #} +
+

{{ about_company_form.about_company.value }}

+
+ {% trans 'редактировать' %} +
+
{% csrf_token %} + +
+ +
+ +
+ {{ about_company_form.about_company }} +
+
+ +
+ +
+ +
+
+ + {% trans 'закрыть' %} +
+
+
+ {# END description #} +
+ +
+
+ {% trans 'редактировать профиль' %} + {% trans 'завершить редактирование' %} +
+ +
+ {% trans 'редактировать' %} +
+
{% csrf_token %} + +
+ +
+ +
+ {{ social_form.facebook }} +
+
+ +
+ +
+ {{ social_form.linkedin }} +
+
+ +
+ +
+ {{ social_form.vk }} +
+
+ +
+ +
+ {{ social_form.twitter }} +
+
+ +
+ +
+ +
+
+ + {% trans 'закрыть' %} +
+
+
+
+ {# contacts #} + +
+ +
+ {# about #} +
+
{% trans 'О себе:' %}
+ +
+

{{ about_form.about.value }}

+ +
+ {% trans 'редактировать' %} +
+
{% csrf_token %} + +
+ +
+ +
+ {{ about_form.about }} +
+
+ +
+ +
+ +
+
+ + {% trans 'закрыть' %} +
+
+
+
+ {# END about #} + +
+
+
+ +{% block scripts %} + + +{% endblock %} \ No newline at end of file diff --git a/templates/client/includes/accounts/simple_user.html b/templates/client/includes/accounts/simple_user.html new file mode 100644 index 00000000..b13efb3a --- /dev/null +++ b/templates/client/includes/accounts/simple_user.html @@ -0,0 +1,102 @@ +{% load static %} +{% load i18n %} +{% load template_filters %} + + +
+
+ +
+
+
+ {% if member.profile.country %} + {{ member.profile.country }}, {{ member.profile.city }} + {% endif %} +
+
{{ member.get_full_name }}
+
+ +
{{ member.profile.position }} + {% if member.company %} + в “{{ member.company }}” + {% else %} + {{ member.profile.work }} + {% endif %} +
+ +
+ {{ member.profile.about_company|safe }} +
+ +
+ +
+
+ {% if user.is_authenticated %} + {% trans 'отправить сообщение' %} + {% endif %} + +
    + {% if member.profile.facebook %} +
  • Facebook
  • + {% endif %} + {% if member.profile.linkedin %} +
  • LinkedIn
  • + {% endif %} + {% if member.profile.vk %} +
  • В контакте
  • + {% endif %} + {% if member.profile.twitter %} +
  • Twitter
  • + {% endif %} +
+
+ + +
+ +
+ +
+
{% trans 'О себе' %}:
+ {{ member.profile.about|safe }} +
+ +
+ +
+
\ No newline at end of file