Esempio n. 1
0
from libs.djcontrib.conf.urls import decorated_patterns
from libs.djcontrib.utils.decorators import combo, obj_by_generic_pk, obj_by_pk
from libs.moderation.models import ModeratedObject
from libs.permitter.decorators import check_perm

from nkmoderation.perms import CanFlagObject, CanModerateContent, CanModerateObject

from . import views

moderated_obj_by_pk = obj_by_pk(ModeratedObject,
                                url_kwarg='moderated_object_id')

urlpatterns = decorated_patterns(
    '',
    combo(obj_by_generic_pk(), check_perm(CanFlagObject)),
    url(r'^ilmoita-asiaton-sisalto/(?P<content_type_id>\d+)/(?P<object_id>\d+)/$',
        views.FlagContentView.as_view(),
        name='flag_content'),
) + decorated_patterns(
    '', combo(moderated_obj_by_pk, check_perm(CanModerateObject)),
    url(r'^moderointi/(?P<moderated_object_id>\d+)/hyvaksy/$',
        views.ApproveModeratedObject.as_view(),
        name='approve_object'),
    url(r'^moderointi/(?P<moderated_object_id>\d+)/poista/$',
        views.RejectModeratedObject.as_view(),
        name='reject_object'),
    url(r'^moderointi/(?P<moderated_object_id>\d+)/poista/$',
        views.RejectModeratedObject.as_view(),
        name='reject_object')
) + decorated_patterns(
    '',
Esempio n. 2
0
from django.conf.urls import patterns, url

from libs.djcontrib.conf.urls import decorated_patterns
from libs.djcontrib.utils.decorators import combo, obj_by_generic_pk, obj_by_pk
from libs.moderation.models import ModeratedObject
from libs.permitter.decorators import check_perm

from nkmoderation.perms import CanFlagObject, CanModerateContent, CanModerateObject

from . import views


moderated_obj_by_pk = obj_by_pk(ModeratedObject, url_kwarg='moderated_object_id')

urlpatterns = decorated_patterns('', combo(obj_by_generic_pk(),
                                           check_perm(CanFlagObject)),
    url(r'^ilmoita-asiaton-sisalto/(?P<content_type_id>\d+)/(?P<object_id>\d+)/$',
        views.FlagContentView.as_view(), name='flag_content'),
) + decorated_patterns('', combo(moderated_obj_by_pk, check_perm(CanModerateObject)),
    url(r'^moderointi/(?P<moderated_object_id>\d+)/hyvaksy/$',
        views.ApproveModeratedObject.as_view(), name='approve_object'),
    url(r'^moderointi/(?P<moderated_object_id>\d+)/poista/$',
        views.RejectModeratedObject.as_view(), name='reject_object'),
    url(r'^moderointi/(?P<moderated_object_id>\d+)/poista/$',
        views.RejectModeratedObject.as_view(), name='reject_object')
) + decorated_patterns('', check_perm(CanModerateContent),
    url(r'^moderointi/(?P<content_type_id>\d+)/(?P<object_id>\d+)/syy/$',
        views.ApproveModeratedObject.as_view(), name='approve_object'),
)
Esempio n. 3
0
    url(r'^nollaa-salasana/vahvista/(?P<uidb64>[0-9A-Za-z_\-]+)'
         '/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        auth.password_reset_confirm,
        name='password_reset_confirm',
        kwargs={
            'template_name': 'account/user_reset_password_confirm.html',
            'post_reset_redirect': 'account:password_reset_ready'
        }),
    url(r'^nollaa-salasana/valmis/$',
        FlashRedirectView.as_view(
            message=_("Salasanasi on vaihdettu. Voit nyt kirjautua sisään "
                      "käyttäen uutta salasanaasi."),
            pattern_name='account:login'
        ), name='password_reset_ready')
) + decorated_patterns('', combo(obj_by_pk(User, 'user_id'), check_perm(CanViewUser)),
    url(r'^(?P<user_id>\d+)/$',
        obj_by_pk(User, 'user_id')(views.UserProfileView.as_view()), name='profile'),
) + decorated_patterns('', combo(obj_by_pk(User, 'user_id'), check_perm(CanEditUser)),
    url(r'(?P<user_id>\d+)/asetukset/$', views.UserSettingsView.as_view(),
        name='settings'),
    url(r'(?P<user_id>\d+)/nayta-asetukset/',
        views.UserSettingsDetailView.as_view(),
        name='settings_detail'),
    url(r'(?P<user_id>\d+)/muokkaa-asetukset/',
        views.UserSettingsEditView.as_view(),
        name='settings_edit'),
    url(r'(?P<user_id>\d+)/asetukset/kuva/$', views.ProfilePictureView.as_view(),
        name='profile_picture'),
    url(r'(?P<user_id>\d+)/asetukset/kuva/muokkaa/$',
        legacy_json_plaintext(views.EditProfilePictureView.as_view()),
        name='edit_profile_picture'),
    url(r'(?P<user_id>\d+)/asetukset/kuva/rajaa/$',
Esempio n. 4
0
    url(r'idean-kysely/(?P<survey_id>\d+)/avaa/$', survey_as_obj(
        check_perm(CanOpenSurvey)(views.IdeaSurveyStatusChangeView.as_view(
            status=IdeaSurvey.STATUS_OPEN))), name='survey_open'),
    url(r'idean-kysely/(?P<survey_id>\d+)/sulje/$', survey_as_obj(
        check_perm(CanCloseSurvey)(views.IdeaSurveyStatusChangeView.as_view(
            status=IdeaSurvey.STATUS_CLOSED))), name='survey_close'),
    url(r'idean-kysely/(?P<survey_id>\d+)/poista/$', survey_as_obj(
        check_perm(CanDeleteSurvey)(views.DeleteIdeaSurveyView.as_view())),
        name='survey_delete'),
    url(r'idean-kysely/(?P<survey_id>\d+)/tulokset-pdf/$', survey_as_obj(
        check_perm(ShowSurveyResults)(views.SurveyResultsToPdfView.as_view())),
        name='survey_results'),
) + decorated_patterns('', combo(initiative_as_obj, check_perm(CanVoteIdea)),
     url(r'ideat/(?P<initiative_id>\d+)/kannata/$',
         views.IdeaVoteView.as_view(choice=Vote.VOTE_UP),
         name='support_idea'),
     url(r'ideat/(?P<initiative_id>\d+)/vastusta/$',
         views.IdeaVoteView.as_view(choice=Vote.VOTE_DOWN),
         name='oppose_idea'),
) + decorated_patterns('', initiative_as_obj,
    url(r'kysymykset/(?P<initiative_id>\d+)/$', views.QuestionDetailView.as_view(),
        name='question_detail'),
    url(r'kysymykset/(?P<initiative_id>\d+)/kommentointi/$',
        nkcomments.CommentBlockView.as_view(model=Question,
                                 pk_url_kwarg='initiative_id'),
        name='comment_block_question'),
) + decorated_patterns('', combo(initiative_as_obj, check_perm(CanViewIdea)),
    url(r'ideat/(?P<initiative_id>\d+)/$', views.IdeaDetailView.as_view(),
        name='idea_detail'),
    url(r'ideat/(?P<initiative_id>\d+)/pdf-lataus/$',
        views.IdeaToPdf.as_view(), kwargs={'download': True},
        name='idea_to_pdf_download'),
Esempio n. 5
0
urlpatterns = decorated_patterns(
    "",
    combo(survey_as_obj, check_perm(CanEditSurvey)),
    url(
        r"^kysely/(?P<survey_id>\d+)/",
        include(
            patterns(
                "",
                url(
                    r"^elementti/(?P<element_id>\d+)/",
                    include(patterns(
                        "",
                        url(r"^nosta/$",
                            views.SurveyElementMoveView.as_view(
                                direction="up"),
                            name="move_up"),
                        url(r"^laske/$",
                            views.SurveyElementMoveView.as_view(
                                direction="down"),
                            name="move_down"),
                        url(r"^poista/$",
                            views.SurveyElementDeleteView.as_view(),
                            name="delete"),
                    ),
                            namespace="element")),
                url(r"^sivu/uusi/$",
                    views.SurveyPageCreateView.as_view(),
                    name="create_page"),
                url(
                    r"^valiotsikko/",
                    include(
                        patterns(
                            "",
                            url(r"^uusi/$",
                                views.SurveySubtitleFormView.as_view(),
                                name="create_subtitle"),
                            url(r"^(?P<subtitle_id>\d+)/muokkaa/$",
                                views.SurveySubtitleFormView.as_view(),
                                name="update_subtitle"),
                            url(r"^(?P<subtitle_id>\d+)/$",
                                views.SurveySubtitleAnswerView.as_view(),
                                name="subtitle"),
                        ))),
                url(
                    r"^kysymys/",
                    include(
                        patterns(
                            "survey.views",
                            url(
                                name="question",
                                regex="^(?P<question_id>\d+)/$",
                                view="question_answer",
                            ),
                            url(
                                name="update_question",
                                regex="^(?P<question_id>\d+)/muokkaa/$",
                                view="question_form",
                            ),
                            url(
                                name="create_text_question",
                                regex=r"^uusi/teksti/$",
                                view="question_form_text",
                            ),
                            url(
                                name="create_number_question",
                                regex="^uusi/numero/$",
                                view="question_form_number",
                            ),
                            url(
                                name="create_radio_question",
                                regex="^uusi/yksivalinta/$",
                                view="question_form_radio",
                            ),
                            url(
                                name="create_checkbox_question",
                                regex="^uusi/monivalinta/$",
                                view="question_form_checkbox",
                            ),
                        ))),
            ))),
)
Esempio n. 6
0
from .perms import CanVoteComment, CanDeleteComment

urlpatterns = patterns(
    'django_comments.views',
    url(r'^(?P<initiative_id>\d+)/post/$',
        combo(obj_by_pk(Initiative, "initiative_id"),
              check_perm(CanCommentInitiative))(views.post_comment),
        name='post-comment'),
)

# Votes
urlpatterns += decorated_patterns(
    "",
    combo(obj_by_pk(CustomComment, "comment_id"), check_perm(CanVoteComment)),
    url(r'^(?P<comment_id>\d+)/kannata/$',
        views.VoteCommentView.as_view(choice=Vote.VOTE_UP),
        name="support_comment"),
    url(r'^(?P<comment_id>\d+)/vastusta/$',
        views.VoteCommentView.as_view(choice=Vote.VOTE_DOWN),
        name="oppose_comment"))

# Comment deletion/edit
urlpatterns += decorated_patterns(
    '',
    obj_by_pk(CustomComment, 'pk'),
    url(r'^(?P<pk>\d+)/poista/$',
        check_perm(CanDeleteComment)(views.DeleteCommentView.as_view()),
        name='delete_comment'),
    url(r'^(?P<pk>\d+)/muokkaa/$',
        check_perm(CanEditComment)(views.EditCommentView.as_view()),
        name='edit_comment'),
Esempio n. 7
0
# coding=utf-8

from __future__ import unicode_literals

from django.conf import settings
from django.conf.urls import patterns, include, url
from django.views.generic.base import RedirectView

from libs.djcontrib.conf.urls import decorated_patterns
from libs.djcontrib.utils.decorators import combo
from openapi.decorators import swagger_content_type_hack, swagger_api_description_hack

from .routers import router


urlpatterns = patterns('',
    url('^$', RedirectView.as_view(url='/api/open/%s/' % settings.OPEN_API['version'],
                                   permanent=False), name='root'),
    url('^0.1/', include(router.urls))
) + decorated_patterns('', combo(swagger_content_type_hack, swagger_api_description_hack),
    url(r'^docs/', include('rest_framework_swagger.urls'))
)
Esempio n. 8
0
     '/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
     auth.password_reset_confirm,
     name='password_reset_confirm',
     kwargs={
         'template_name': 'account/user_reset_password_confirm.html',
         'post_reset_redirect': 'account:password_reset_ready'
     }),
 url(r'^nollaa-salasana/valmis/$',
     FlashRedirectView.as_view(message=_(
         "Salasanasi on vaihdettu. Voit nyt kirjautua sisään "
         "käyttäen uutta salasanaasi."),
                               pattern_name='account:login'),
     name='password_reset_ready')) + decorated_patterns(
         '',
         combo(obj_by_pk(User, 'user_id'), check_perm(CanViewUser)),
         url(r'^(?P<user_id>\d+)/$',
             obj_by_pk(User, 'user_id')(views.UserProfileView.as_view()),
             name='profile'),
     ) + decorated_patterns(
         '',
         combo(obj_by_pk(User, 'user_id'), check_perm(CanEditUser)),
         url(r'(?P<user_id>\d+)/asetukset/$',
             views.UserSettingsView.as_view(),
             name='settings'),
         url(r'(?P<user_id>\d+)/nayta-asetukset/',
             views.UserSettingsDetailView.as_view(),
             name='settings_detail'),
         url(r'(?P<user_id>\d+)/muokkaa-asetukset/',
             views.UserSettingsEditView.as_view(),
             name='settings_edit'),
         url(r'(?P<user_id>\d+)/asetukset/kuva/$',
Esempio n. 9
0
# coding=utf-8

from __future__ import unicode_literals

from django.conf.urls import patterns, url
from libs.djcontrib.conf.urls import decorated_patterns
from libs.djcontrib.utils.decorators import combo, obj_by_generic_pk
from libs.permitter.decorators import check_perm
from libs.djcontrib.utils.decorators import obj_by_pk

from . import views
from nuka.perms import IsAuthenticated
from account.perms import CanEditUser
from account.models import User

urlpatterns = decorated_patterns(
    '',
    combo(obj_by_generic_pk(), check_perm(IsAuthenticated)),
    url(r'^seuraa/(?P<content_type_id>\d+)/(?P<object_id>\d+)/$',
        views.AddOrRemoveIdeaView.as_view(),
        name='add_or_remove_idea'),
) + decorated_patterns(
    '', combo(obj_by_pk(User, 'user_id'), check_perm(CanEditUser)),
    url(r'^(?P<user_id>\d+)/seuratut/muokkaa/(?P<ct_id>\d+)/$',
        views.UserFavoriteEditView.as_view(),
        name='favorite_edit'),
    url(r'^(?P<user_id>\d+)/seuratut/nayta/(?P<ct_id>\d+)/$',
        views.UserFavoriteDetailView.as_view(),
        name='favorite_detail'))
Esempio n. 10
0
    url(r'^(?P<pk>\d+)/arkistoi/',
        org_by_pk(check_perm(IsModerator)(views.OrganizationArchiveView.as_view())),
        name='archive'),
    url(r'^(?P<pk>\d+)/piilota/',
        org_by_pk(
            check_perm(IsModerator)(views.OrganizationSetActiveView.as_view(active=False))
        ),
        name='deactivate'),
    url(r'^(?P<pk>\d+)/aktivoi/',
        org_by_pk(
            check_perm(IsModerator)(views.OrganizationSetActiveView.as_view(active=True))
        ),
        name='activate'),
) + decorated_patterns('', combo(org_by_pk, check_perm(CanViewOrganization)),
    url(r'^(?P<pk>\d+)/$', SlugRedirect.as_view(model=Organization, permanent=False),
        name='detail_pk'),
    url(r'^(?P<pk>\d+)/lista/$', views.OrganizationIdeaList.as_view(), name='idea_list'),
    *partial_detail_urls
) + decorated_patterns('', combo(obj_by_slug, check_perm(CanViewOrganization)),
    url(r'^(?P<slug>[\w-]+)/$', views.OrganizationDetailView.as_view(), name='detail'),
) + decorated_patterns('', combo(org_by_pk, check_perm(CanEditOrganization)),
    url(r'^(?P<pk>\d+)/kuva/$', views.PictureView.as_view(),
        name='picture'),
    url(r'^(?P<pk>\d+)/kuva/muokkaa/$',
        legacy_json_plaintext(views.EditPictureView.as_view()),
        name='edit_picture'),
    url(r'^(?P<pk>\d+)/kuva/rajaa/$',
        views.CropProfilePictureView.as_view(), name='crop_picture'),
    url(r'^(?P<pk>\d+)/kuva/poista/$',
        views.DeletePictureView.as_view(),
        name='delete_picture'),
    *partial_edit_patterns
Esempio n. 11
0
from django.conf.urls import url

from libs.djcontrib.conf.urls import decorated_patterns
from libs.djcontrib.utils.decorators import combo
from libs.permitter.decorators import check_perm
from libs.djcontrib.utils.decorators import obj_by_pk

from account.models import User

from . import views
from .perms import CanAccessAdminPanel, CanEditUser


urlpatterns = decorated_patterns('', check_perm(CanAccessAdminPanel),
    url(r'^moderointi/$', views.ModerationQueueView.as_view(), name='moderation_queue'),
    url(r'^organisaatiot/$', views.ModerationOrganizationQueueView.as_view(), name='moderation_organization_queue'),
    url(r'^kayttajat/$', views.UsersView.as_view(), name='users'),
    url(r'^kayttajat/(?P<filter>\w+)/$', views.UsersView.as_view(), name='users'),
)

urlpatterns += decorated_patterns(
    '',
    combo(obj_by_pk(User), check_perm(CanEditUser)),
    url(
        r'^kayttajat/(?P<pk>\d+)/muokkaa/$',
        views.EditUserView.as_view(),
        name='users_edit'
    ),
    url(
        r'^kayttajat/(?P<pk>\d+)/vaihda_salasana/$',
        views.SetPasswordView.as_view(),
        name='change_password'
Esempio n. 12
0
            check_perm(IsModerator)(views.OrganizationArchiveView.as_view())),
        name='archive'),
    url(r'^(?P<pk>\d+)/piilota/',
        org_by_pk(
            check_perm(IsModerator)(
                views.OrganizationSetActiveView.as_view(active=False))),
        name='deactivate'),
    url(r'^(?P<pk>\d+)/aktivoi/',
        org_by_pk(
            check_perm(IsModerator)(
                views.OrganizationSetActiveView.as_view(active=True))),
        name='activate'),
) + decorated_patterns(
    '', combo(org_by_pk, check_perm(CanViewOrganization)),
    url(r'^(?P<pk>\d+)/$',
        SlugRedirect.as_view(model=Organization, permanent=False),
        name='detail_pk'),
    url(r'^(?P<pk>\d+)/lista/$',
        views.OrganizationIdeaList.as_view(),
        name='idea_list'), *partial_detail_urls) + decorated_patterns(
            '',
            combo(obj_by_slug, check_perm(CanViewOrganization)),
            url(r'^(?P<slug>[\w-]+)/$',
                views.OrganizationDetailView.as_view(),
                name='detail'),
        ) + decorated_patterns(
            '', combo(org_by_pk, check_perm(CanEditOrganization)),
            url(r'^(?P<pk>\d+)/kuva/$',
                views.PictureView.as_view(),
                name='picture'),
            url(r'^(?P<pk>\d+)/kuva/muokkaa/$',
                legacy_json_plaintext(views.EditPictureView.as_view()),
Esempio n. 13
0
from .perms import CanVoteComment, CanDeleteComment


urlpatterns = patterns('django_comments.views',
    url(r'^(?P<initiative_id>\d+)/post/$', combo(obj_by_pk(Initiative, "initiative_id"),
                          check_perm(CanCommentInitiative))(views.post_comment), name='post-comment'),
)

# Votes
urlpatterns += decorated_patterns(
    "",
    combo(obj_by_pk(CustomComment, "comment_id"), check_perm(CanVoteComment)),
    url(
        r'^(?P<comment_id>\d+)/kannata/$',
        views.VoteCommentView.as_view(choice=Vote.VOTE_UP),
        name="support_comment"
    ),
    url(
        r'^(?P<comment_id>\d+)/vastusta/$',
        views.VoteCommentView.as_view(choice=Vote.VOTE_DOWN),
        name="oppose_comment"
    )
)

# Comment deletion/edit
urlpatterns += decorated_patterns(
    '',
    obj_by_pk(CustomComment, 'pk'),
    url(r'^(?P<pk>\d+)/poista/$',
        check_perm(CanDeleteComment)(views.DeleteCommentView.as_view()),
        name='delete_comment'
    ),
Esempio n. 14
0
# coding=utf-8

from __future__ import unicode_literals

from django.conf import settings
from django.conf.urls import patterns, include, url
from django.views.generic.base import RedirectView

from libs.djcontrib.conf.urls import decorated_patterns
from libs.djcontrib.utils.decorators import combo
from openapi.decorators import swagger_content_type_hack, swagger_api_description_hack

from .routers import router

urlpatterns = patterns(
    '',
    url('^$',
        RedirectView.as_view(
            url='/api/open/%s/' % settings.OPEN_API['version'],
            permanent=False),
        name='root'), url('^0.1/', include(router.urls))) + decorated_patterns(
            '', combo(swagger_content_type_hack, swagger_api_description_hack),
            url(r'^docs/', include('rest_framework_swagger.urls')))
Esempio n. 15
0
# coding=utf-8

from __future__ import unicode_literals

from django.conf.urls import patterns, url
from libs.djcontrib.conf.urls import decorated_patterns
from libs.djcontrib.utils.decorators import combo, obj_by_generic_pk
from libs.permitter.decorators import check_perm
from libs.djcontrib.utils.decorators import obj_by_pk

from . import views
from nuka.perms import IsAuthenticated
from account.perms import CanEditUser
from account.models import User

urlpatterns = decorated_patterns('', combo(obj_by_generic_pk(),
                                           check_perm(IsAuthenticated)),
    url(r'^seuraa/(?P<content_type_id>\d+)/(?P<object_id>\d+)/$',
        views.AddOrRemoveIdeaView.as_view(), name='add_or_remove_idea'),
) + decorated_patterns('', combo(obj_by_pk(User, 'user_id'), check_perm(CanEditUser)),
    url(r'^(?P<user_id>\d+)/seuratut/muokkaa/(?P<ct_id>\d+)/$',
        views.UserFavoriteEditView.as_view(),
        name='favorite_edit'),
    url(r'^(?P<user_id>\d+)/seuratut/nayta/(?P<ct_id>\d+)/$',
        views.UserFavoriteDetailView.as_view(),
        name='favorite_detail')
)