def post(self, request): common = CommonView(self) # Astuce : dupliquer un enregistrement complet = le chercher + pk=None # http://stackoverflow.com/questions/4733609/ # how-do-i-clone-a-django-model-instance-object-and-save-it-to-the-database try: activite = Activite.objects.get(pk=int(request.POST['activite'])) except ValueError: return redirect('my_home_index') # hack -> juste redirect personne = common.infos['personne'] # Chercher les pk des personnes pour qui on a déjà partagé l'activité : deja_shared = set( ActiviteShared.objects.filter(activite=activite).values_list( 'dst__pk', flat=True)) contacts_pks = set([p.pk for p in personne.contacts]) for v in request.POST.getlist('contacts[]'): try: if v == 'on': # c'était la case "tout cocher" -> ignorer continue v = int(v) if v not in contacts_pks: # hack return redirect('my_home_index') if v in deja_shared: # déjà partagé continue a_s = ActiviteShared.objects.create( src=personne, dst=Personne.objects.get(pk=v), activite=activite) a_s.save() except ValueError: # hack return redirect('my_home_index') return redirect('my_home_index')
def get_context_data(self, **kwargs): common = CommonView(self, **kwargs) context = super(IndexView, self).get_context_data(**kwargs) context['common'] = common.infos context['titre'] = _('Home') current = common.infos['personne'] # À partir de là on a les id -> ressortir les personnes avec ces ids. # Pagination des résultats contacts = [ {'form': MessageSendForm(obj_bd=p, champ='id_personne'), 'contact': p, } for p in current.relations_of_type(PersonneEnums.RELATION_AMI)] paginator = HQFPaginator(contacts, 6) try: page = int(self.request.GET.get('page', 1)) except ValueError: page = 1 try: paginator.set_around(page, 3) contacts = paginator.page(page) except PageNotAnInteger: # Si page n'est pas un entier, renvoyer la page 1. contacts = paginator.page(1) except EmptyPage: # Si page hors limites (ex. 9999) renvoyer la dernière page. contacts = paginator.page(paginator.num_pages) context['contacts'] = contacts if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] return context
def get_context_data(self, **kwargs): # 'contact_id' = param de l'URL => dans kwargs => faire suivre kwargs : common = CommonView(self, **kwargs) context = super(NotCompleteView, self).get_context_data(**kwargs) context['common'] = common.infos if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] return context
def get_context_data(self, **kwargs): common = CommonView(self) context = super(InviteFriendView, self).get_context_data(**kwargs) context['common'] = common.infos context['titre'] = _(u'Invite friends') if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] return context
def get_context_data(self, **kwargs): common = CommonView(self) context = super(LoginView, self).get_context_data(**kwargs) context['common'] = common.infos if self.request.session.get('message'): context['message'] = self.request.session['message'] del self.request.session['message'] context['titre'] = _(u'Login') context['form'] = LoginForm() return context
def get_context_data(self, **kwargs): common = CommonView(self) context = super(ErrorView, self).get_context_data(**kwargs) context['common'] = common.infos context['titre'] = _(u'Error') # Message éventuel à afficher : if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] return context
def get_context_data(self, **kwargs): common = CommonView(self, **kwargs) context = super(RemarksAndTestimoniesView, self).get_context_data(**kwargs) context['common'] = common.infos if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] context['form_remarks'] = RemarksForm() context['form_testimonies'] = TestimonyForm() return context
def get_context_data(self, **kwargs): common = CommonView(self) context = super(EditView, self).get_context_data(**kwargs) context['common'] = common.infos context['titre'] = _('My account') if self.object: context['url_photo_profil'] = self.object.url_photo_profil context['url_photo_banniere'] = self.object.url_photo_banniere else: # Calculer photo sans rien = photo "vide" context['url_photo_profil'] = PictureURL().get_url() context['url_photo_banniere'] = PictureURL().get_url() # (!) Formes supplémentaires : context['form_visibilite'] = ProfileVisibiliteForm( instance=common.infos['personne']) reset_password = self.request.session.get('reset_password') if reset_password: del self.request.session['reset_password'] context['form_password'] = ProfilePasswordForm( show_field_old_password=not reset_password) context['form_account_desactivate'] = ProfileDesactivateForm() context['form_account_delete'] = ProfileDeleteForm() context['form_newsletter_configuration'] = \ ProfileNewsletterConfigurationForm({ 'newsletter_configuration': common.infos['personne'].newsletter_configuration }) # Comme partout ailleurs, effacer le message s'il y en avait un : if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] # Publicités : context['publicites_gauche'] = \ self.publicites(Publicite.PUBLICITE_MY_PROFILE_GAUCHE) context['publicites_droite'] = \ self.publicites(Publicite.PUBLICITE_MY_PROFILE_DROITE) p = Personne.objects.get(user=self.request.user) # Progression : if self.request.session.get('progression', None) is None: self.request.session['progression'] = False if not self.request.session['progression']: self.request.session['progression'] = True context['progression'] = self.progression(self.request.user, p) return context
def get_context_data(self, **kwargs): # 'contact_id' = param de l'URL => dans kwargs => faire suivre kwargs : common = CommonView(self, **kwargs) context = super(ContactDetailView, self).get_context_data(**kwargs) context['common'] = common.infos try: contact = Personne.objects.get(pk=kwargs['contact_id']) except Personne.DoesNotExist: # pas d'index 'contact' crée -> gestion plus tard via get() return context context['contact'] = contact # pagination for contacts contact_contacts = contact.contacts # Pagination paginator = HQFPaginator(contact_contacts, 6) try: page = int(self.request.GET.get('page', 1)) except ValueError: page = 1 try: paginator.set_around(page, 3) contact_contacts = paginator.page(page) except PageNotAnInteger: # Si page n'est pas un entier, renvoyer la page 1. contact_contacts = paginator.page(1) except EmptyPage: # Si page est hors limites, (ex. 9999), renvoyer la dernière page. contact_contacts = paginator.page(paginator.num_pages) context['contact_contacts'] = contact_contacts context['form_send_message'] = MessageSendForm(obj_bd=contact, champ='id_personne') p = common.infos['personne'] convs = Conversation.between(p, contact) if len(convs): # get() = pour avoir un objet (!= QuerySet) # normalement qu'une seule conversation avec des messages : c = Conversation.objects.get(pk=convs[0]) context['conversation'] = c context['conversation_form'] = MessageSendForm( obj_bd=c, champ='id_conversation') if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] return context
def get_context_data(self, **kwargs): common = CommonView(self) context = super(RegisterView, self).get_context_data(**kwargs) context['agree_with_toc_and_tos'] = \ _("By clicking the Sign Up button, you agree to our " "<a href=\"{0}\" target=\"_blank\">Terms & Conditions</a> " "and confirm that you have read our " "<a href=\"{1}\" target=\"_blank\">Data Usage Policy</a>, " "including our use of Cookies, mobile app, and APIs " "(Facebook, Twitter, Google+, LinkedIn, etc.).")\ .format( reverse('terms_and_conditions'), reverse('terms_of_service') ) context['common'] = common.infos context['titre'] = _('Sign up') if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] return context
def get_context_data(self, **kwargs): common = CommonView(self) context = super(BlogView, self).get_context_data(**kwargs) context['common'] = common.infos # aller chercher tous "blogs" de la langue en cours ids = Activite.objects.filter( Q(activite__exact=Activite.ACTIVITE_BLOG, blog_traduit__locale=common.infos['locale'])).values_list( 'blog_traduit__pk') context['blogs'] = BlogTraduit.objects.filter(pk__in=ids).order_by( '-blog__ordre_si_top', '-blog__date_publication', '-blog__date_last_modif') context['blog_title'] = _('Cogofly - Blog') context['blog_contact_us'] = _( 'If you require any more information or have any questions, ' 'please feel free to contact us by email by clicking ' '<a href="mailto:[email protected]" target="_blank">' 'here ' '</a>') return context
def get_context_data(self, **kwargs): common = CommonView(self, **kwargs) context = super(NotificationsView, self).get_context_data(**kwargs) context['common'] = common.infos # Pagination : écraser les likes likes = context['common']['notifications']['likes'] paginator = HQFPaginator(likes, 5) try: page = int(self.request.GET.get('p_like', 1)) except ValueError: page = 1 try: paginator.set_around(page, 3) likes = paginator.page(page) except PageNotAnInteger: # Si page n'est pas un entier, renvoyer la page 1. likes = paginator.page(1) except EmptyPage: # Si page est hors limites, (ex. 9999), renvoyer la dernière page. likes = paginator.page(paginator.num_pages) context['common']['notifications']['likes'] = likes context['titre'] = _(u'Notifications') p = common.infos['personne'] convs_non_lues = Conversation.objects.filter( Q(messages__dst=p, messages__is_read=False, messages__date_v_fin__isnull=True)).distinct() context['conversations'] = [{ 'form': MessageSendForm(obj_bd=c, champ='id_conversation'), 'conversation': c } for c in convs_non_lues] l = [] for m in Message.objects.filter(dst=p, dst_visible=True)\ .order_by('date_last_modif'): for c in m.conversations.all().exclude(pk__in=convs_non_lues): if c.pk not in l: l.append(c.pk) convs_lues = [Conversation.objects.get(pk=int(pk)) for pk in l] context['conversations_lues'] = [{ 'form': MessageSendForm(obj_bd=c, champ='id_conversation'), 'conversation': c } for c in convs_lues] # Pagination paginator = HQFPaginator(context['conversations_lues'], 8) try: page = int(self.request.GET.get('p_convs', 1)) except ValueError: page = 1 try: paginator.set_around(page, 3) context['conversations_lues'] = paginator.page(page) except PageNotAnInteger: # Si page n'est pas un entier, renvoyer la page 1. context['conversations_lues'] = paginator.page(1) except EmptyPage: # Si page est hors limites, (ex. 9999), renvoyer la dernière page. context['conversations_lues'] = paginator.page(paginator.num_pages) return context
def get_context_data(self, **kwargs): common = CommonView(self) context = super(IndexView, self).get_context_data(**kwargs) context['common'] = common.infos context['titre'] = _('Home') p = Personne.objects.get(user=self.request.user) context['activites'] = self.activites(p, common.infos['locale']) context['liked'] = [ liked.activite for liked in PersonneLiked.objects.filter( activite__in=context['activites'], liked__exact=True, src=p, date_v_fin__isnull=True) ] context['liked_person'] = [ liked_p.dst for liked_p in PersonneLiked.objects.filter( activite__isnull=True, liked__exact=True, src=p, date_v_fin__isnull=True) ] context['activites'] = [{ 'objet': a, 'form': MessageSendForm(obj_bd=a, champ='id_activite'), 'form_comment': CommentSendForm(obj_bd=a, champ='id_comment_activite'), 'comments': ActiviteComments.objects.filter(activite_dst=a) } for a in context['activites']] context['express_yourself'] = ExpressYourselfForm() # Pagination paginator = HQFPaginator(context['activites'], 8) try: page = int(self.request.GET.get('page', 1)) except ValueError: page = 1 try: paginator.set_around(page, 3) context['activites'] = paginator.page(page) except PageNotAnInteger: # If not integer, back to page 1. context['activites'] = paginator.page(1) except EmptyPage: # If out of bound (ex. 9999), send latest page context['activites'] = paginator.page(paginator.num_pages) # Message (if there's one) if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] # Publicités context['publicites_gauche'] = \ self.publicites(Publicite.PUBLICITE_FIL_ACTUALITE_GAUCHE) context['publicites_droite'] = \ self.publicites(Publicite.PUBLICITE_FIL_ACTUALITE_DROITE) # Travels if self.request.session.get('warn_no_travels', None) is None: self.request.session['warn_no_travels'] = True if PersonneTravel.objects.filter( personne=p, date_v_fin__isnull=True).count() == 0: self.request.session['warn_no_travels'] = True context['warn_no_travels'] = True # Progression if self.request.session.get('progression', None) is None: self.request.session['progression'] = False if not self.request.session['progression']: self.request.session['progression'] = True context['progression'] = self.progression(self.request.user, p) return context
def get_context_data(self, **kwargs): common = CommonView(self, **kwargs) context = super(SearchView, self).get_context_data(**kwargs) # ----------------------------------------------------- # Analyse de tout ce qu'il y a dans le get pour faire la requête : g = self.request.GET travel = self.clean_html(g.get('travel'), '') s_dd = self.clean_int(self, g.get('date_start_1'), '**') s_mm = self.clean_int(self, g.get('date_start_0'), '**') s_yy = self.clean_int(self, g.get('date_start_2'), '-1') e_dd = self.clean_int(self, g.get('date_end_1'), '**') e_mm = self.clean_int(self, g.get('date_end_0'), '**') e_yy = self.clean_int(self, g.get('date_end_2'), '-1') nb_enfants = self.clean_int(self, g.get('nb_enfants'), -1) sexe = self.clean_int(self, g.get('sexe'), -1) langue = self.clean_int(self, g.get('langue'), -1) niveau_etudes = self.clean_int(self, g.get('niveau_etudes'), -1) employer_current = self.clean_html(g.get('employer_current')) employer_previous = self.clean_html(g.get('employer_previous')) profession = self.clean_int(self, g.get('profession'), -1) est_fumeur = self.clean_int(self, g.get('est_fumeur'), -1) custom_zodiac_sign = self.clean_int(self, g.get('custom_zodiac_sign'), -1) def mk_datepartial(yy, mm, dd): if yy != '-1': ok = '{:0>4}-{:0>2}-{:0>2}'.format(yy, mm, dd) try: parse_date_partial(ok) return ok except ValidationError: self.request.session['message'] = ( _('Bad dates'), _("Click here to hide this message")) return None # si on précise le jour SANS le mois, virer le jour : if (s_dd != '**') and (s_mm == '**'): s_dd = '**' if (e_dd != '**') and (e_mm == '**'): e_dd = '**' # Vérification que les dates sont valables : s = mk_datepartial(s_yy, s_mm, s_dd) if not s: # Forcer les combos jj et mm à vide s_dd = '**' s_mm = '**' e = mk_datepartial(e_yy, e_mm, e_dd) if not e: # Forcer les combos jj et mm à vide e_dd = '**' e_mm = '**' if not self.request.session.get('message'): # Ok, dates valides (sinon message venant de mk_datepartial()) if s and e and (s > e): # Remettre les dates dans l'ordre : s, e = e, s s_dd, e_dd = e_dd, s_dd s_mm, e_mm = e_mm, s_mm s_yy, e_yy = e_yy, s_yy # --------------------------------------------------------------------- # Construction de la requête finale, prise en compte de tous les champs q = Q() if s: q &= Q(date_start__gte=s) if e: q &= Q(date_end__lte=e) age = self.clean_int(self, g.get('age'), '-1') if age in PersonneEnums.TAB_AGE_ECART: ecart = PersonneEnums.TAB_AGE_ECART[age] n = now() q &= Q(personne__date_naissance__lte=n.replace(year=n.year - ecart['min'])) if ecart['max'] > 0: q &= Q(personne__date_naissance__gte=n.replace(year=n.year - ecart['max'])) if nb_enfants >= 0: q &= Q(personne__nb_enfants__exact=nb_enfants) else: nb_enfants = None if sexe >= 0: q &= Q(personne__sexe__exact=sexe) else: sexe = None if langue >= 0: q &= Q(personne__langue__exact=langue) else: langue = None if niveau_etudes >= 0: q &= Q(personne__niveau_etudes__exact=niveau_etudes) else: niveau_etudes = None if employer_current: q &= Q(personne__employer_current__exact=employer_current) else: employer_current = None if employer_previous: q &= Q(personne__employer_previous__exact=employer_previous) else: employer_previous = None if profession >= 0: q &= Q(personne__profession__exact=profession) else: profession = None if est_fumeur >= 0: q &= Q(personne__est_fumeur__exact=est_fumeur) else: est_fumeur = None if custom_zodiac_sign >= 0: q &= Q(personne__custom_zodiac_sign__exact=custom_zodiac_sign) else: custom_zodiac_sign = None programmes2 = [int(l) for l in g.getlist('programmes2')] activites2 = [int(l) for l in g.getlist('activites2')] hobbies2 = [int(l) for l in g.getlist('hobbies2')] types_permis2 = [int(l) for l in g.getlist('types_permis2')] personnalites2 = [int(l) for l in g.getlist('personnalites2')] langues2 = [int(l) for l in g.getlist('langues2')] if len(q): q = q & Q(personne__est_active=True) & Q( personne__est_detruit=None) print(q) if travel: results = [] # There's a place to search v = TagGoogleMapsTraduit.objects.filter( langue__locale__exact=common.infos['locale'], formatted_address__iexact=travel) if len(v) == 0: # Not already cached -> ask google and add to my db cache try: print('{} not found -> asking google...'.format(travel)) TagGoogleMapsTraduit.make_cache_via_google_maps( text=travel, locale=common.infos['locale']) # Get it again so we're sure everything's fine: v = TagGoogleMapsTraduit.objects.filter( langue__locale__exact=common.infos['locale'], formatted_address__iexact=travel) print('cache done not we have:') print(' // '.join([str(p) for p in v])) except GoogleException as e: self.request.session['message'] = [ _("Nothing found"), _("Google didn't find a town/country with this name"), _("Click here to hide this message") ] # save the search only if town and it's not another page: if len(v): tab = [p.tag_google_maps.pk for p in v] # register if g.get('page', '1') == '1': # remember that search: for p in v: # p = TagGoogleMapsTraduit # -> add the search ps = PersonneSearch.objects.create( personne=common.infos['personne'], search=p) ps.save() results = PersonneTravel.objects.filter( ~Q(personne=common.infos['personne']) & Q(travel__tag_google_maps__in=tab) & q) elif s or e or len(q): results = PersonneTravel.objects.filter( (~Q(personne=common.infos['personne'])) & q) else: results = None # mémo pour me souvenir de comment n'avoir que les ids des personnes, # et non plus les voyages : if results is not None: if isinstance(results, models.QuerySet): # pour faire "tous les choix PRÉSENTS, # le "__in=" ne fonctionne pas, il fait un "OU", alors que # je veux un "ET". Solution = ".filter()" enchaînés : for pk in [int(l) for l in activites2]: results = results.filter(personne__activites2__pk=pk) for pk in [int(l) for l in programmes2]: results = results.filter(personne__programmes2__pk=pk) for pk in [int(l) for l in hobbies2]: results = results.filter(personne__hobbies2__pk=pk) for pk in [int(l) for l in types_permis2]: results = results.filter(personne__types_permis2__pk=pk) for pk in [int(l) for l in personnalites2]: results = results.filter(personne__personnalites2__pk=pk) for pk in [int(l) for l in langues2]: results = results.filter(personne__langues2__pk=pk) results = set(results.values_list('personne', flat=True)) results = Personne.objects.filter(pk__in=results) \ .order_by('-user__last_login', '-date_creation') context['search_results_title'] = _( 'Results matching with your criterias ' 'found: <b>{}</b>').format(results.count()) # Pagination des résultats if common.infos['personne'].id == 585: max_page = 50 else: max_page = 9 paginator = HQFPaginator(results, max_page) try: page = int(self.request.GET.get('page', 1)) except ValueError: page = 1 try: paginator.set_around(page, 3) results = paginator.page(page) except PageNotAnInteger: # Si page n'est pas un entier, renvoyer la page 1. results = paginator.page(1) except EmptyPage: # Si page hors limites (ex. 9999) renvoyer la dernière page. results = paginator.page(paginator.num_pages) context['search_results'] = results # Mémo si plusieurs valeurs # known_languages = self.request.GET.getlist('known_languages') context['common'] = common.infos context['titre'] = _('Search') # reconstruire la forme en ré-injectant les données du GET : context['form_basique'] = SearchBasicForm({ 'travel': travel if travel else '', 'date_start': '{}-{}-{}'.format(s_yy, s_mm, s_dd), 'date_end': '{}-{}-{}'.format(e_yy, e_mm, e_dd), }) # Ajouter une erreur : # context['form_basique'].add_error('travel', u'Erreur test') context['form_avancee'] = SearchAdvancedForm( initial={ 'travel': travel if travel else '', 'date_start': '{}-{}-{}'.format(s_yy, s_mm, s_dd), 'date_end': '{}-{}-{}'.format(e_yy, e_mm, e_dd), 'nb_enfants': nb_enfants, 'sexe': sexe, 'langue': langue, 'niveau_etudes': niveau_etudes, 'employer_current': employer_current, 'employer_previous': employer_previous, 'profession': profession, 'est_fumeur': est_fumeur, 'custom_zodiac_sign': custom_zodiac_sign, 'programmes2': programmes2, 'activites2': activites2, 'hobbies2': hobbies2, 'types_permis2': types_permis2, 'personnalites2': personnalites2, 'langues2': langues2, 'age': age, }) p = Personne.objects.get(user=self.request.user) context['liked_person'] = [ liked_p.dst for liked_p in PersonneLiked.objects.filter( activite__isnull=True, src=p, date_v_fin__isnull=True) ] # Comme un peu partout ailleurs, effacer le message s'il y en avait un : if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] return context
def get_context_data(self, **kwargs): # Méga hack : si jamais il y a une erreur sur la forme, # et que cette erreur fait partie d'une forme qu'on a édité = avec 'pk' # alors la mettre de côté dans form_erreur et à la place, mettre # une forme vide pour faire croire que tout va bien : form = kwargs.get('form') form_erreur_pk = None if hasattr(form, 'cleaned_data') and form.cleaned_data.get('pk'): if not form.is_valid(): # hasattr(form, 'errors') # Mettre de côté cette forme qu'on utilisera plus tard : v = form.cleaned_data.get('travel') v = v.formatted_address \ if type(v) is TagGoogleMapsTraduit else str(v) form_erreur_pk = form.cleaned_data['pk'] form_erreur = PersonneTravelForm( data={ 'pk': form_erreur_pk, 'travel': v, 'date_start': form.cleaned_data.get('date_start'), 'date_end': form.cleaned_data.get('date_end'), 'comments': form.cleaned_data.get('comments'), 'field_photo_1': form.cleaned_data.get( 'field_photo_1'), 'field_photo_2': form.cleaned_data.get( 'field_photo_2'), 'field_photo_3': form.cleaned_data.get( 'field_photo_3'), }) form_erreur.add_error(None, form.errors) # Créer la forme "officielle" = insert = vide kwargs['form'] = PersonneTravelForm({}) common = CommonView(self) context = super(IndexView, self).get_context_data(**kwargs) context['common'] = common.infos context['titre'] = _('My travels') # ------------------------- # Deux sections identiques : 'voyages_passes' et 'voyages_a_venir' : def remplir_context(index, tab): context[index] = [] for ptf in tab: if form_erreur_pk and ptf.pk == form_erreur_pk: context[index].append({'obj': ptf, 'form': form_erreur}) else: context[index].append({ 'obj': ptf, 'form': PersonneTravelForm( initial={ 'pk': ptf.pk, 'travel': ptf.travel.formatted_address, 'date_start': ptf.date_start, 'date_end': ptf.date_end, 'comments': ptf.comments, 'field_photo_1': ptf.photo1, 'field_photo_2': ptf.photo2, 'field_photo_3': ptf.photo3, }) }) p = Personne.objects.get(user=self.request.user) remplir_context('voyages_passes', p.travels_past) # Même boucle que la précédente 'voyages_passes' remplir_context('voyages_a_venir', p.travels_futur) if self.request.session.get('message', None): context['message'] = self.request.session['message'] del self.request.session['message'] # Publicités : context['publicites_gauche'] = \ self.publicites(Publicite.PUBLICITE_VOYAGES_GAUCHE) context['publicites_droite'] = \ self.publicites(Publicite.PUBLICITE_VOYAGES_DROITE) return context
def get_context_data(self, **kwargs): context = super(PremiumView, self).get_context_data(**kwargs) common = CommonView(self) context['common'] = common.infos return context
from django.conf.urls import url from app.views.common import CommonView from app.views.order import OrderView app_name = "app" # common urlpatterns = [ url(r'^common/index$', CommonView.as_view(), name="index"), url(r'^common/introduction$', CommonView.as_view(), name="introduction"), url(r'^common/search$', CommonView.as_view(), name="search"), url(r'^common/shopcart$', CommonView.as_view(), name="shopcart"), url(r'^common/deleteShopcart$', CommonView.as_view(), name="deleteShopcart"), url(r'^common/addShopcart$', CommonView.as_view(), name="addShopcart"), url(r'^common/buynow$', CommonView.as_view(), name="buynow"), url(r'^common/activity$', CommonView.as_view(), name="activity"), url(r'^common/contact$', CommonView.as_view(), name="contact"), url(r'^common/about', CommonView.as_view(), name="about"), url(r'^common/help', CommonView.as_view(), name="help"), url(r'.*/logout$', CommonView.as_view(), name="logout"), url(r'^common/addCollection',CommonView.as_view(),name="addCollection"), url(r'^common/deleteCollection',CommonView.as_view(),name="deleteCollection"), ] # 订单 urlpatterns += [ url(r'^order/success$', OrderView.as_view(), name="success"), url(r'^order/fail$', OrderView.as_view(), name="fail"), url(r'^order/order$', OrderView.as_view(), name="order"), url(r'^order/addOrder$', OrderView.as_view(), name="addOrder"),
def get_context_data(self, **kwargs): common = CommonView(self, **kwargs) context = super(LanguageView, self).get_context_data(**kwargs) context['common'] = common.infos context['titre'] = _(u'Language') return context
def get(self, req, *args, **kwargs): common = CommonView(self) return render(req, self.template_name, { 'common': common.infos, 'titre': _('Home') })