Пример #1
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, 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'),
Пример #2
0
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, 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'),
Пример #3
0
                'account/user_reset_password_link_sent.html'}),
    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()),
Пример #4
0
from nuka.decorators import legacy_json_plaintext
from nuka.perms import IsAuthenticated
from survey.models import Survey
from survey.perms import CanEditSurvey
from .survey_perms import CanViewSurvey, CanOpenSurvey, CanCloseSurvey, CanDeleteSurvey, \
    ShowSurveyResults, CanEditSurveyName
from . import views, forms
from .models import Initiative, Idea, Question, IdeaSurvey
from .perms import CanTransferIdeaForward, CanPublishIdea, \
    CanTransferIdeaToKUAWithoutExtraAction, CanPublishIdeaDecision, \
    CanChangeIdeaSettings, CanArchiveIdea, CanUnArchiveIdea, CanVoteIdea, \
    CanCreateSurvey, CanEditInitiative, CanViewIdea, CanDeleteIdea, CanDeleteQuestion, \
    CanCreateIdeaFromQuestion


initiative_as_obj = obj_by_pk(Initiative, 'initiative_id')
survey_as_obj = obj_by_pk(Survey, 'survey_id')

IDEA_FRAGMENT_URLS = (
    # (url part, template name/url name part, form_class)
    (r'kuva',           'picture',          forms.EditIdeaPictureForm,
     views.IdeaPictureEditView),
    (r'otsikko',        'title',            forms.EditInitiativeTitleForm),
    (r'kuvaus',         'description',      forms.EditInitiativeDescriptionForm),
    (r'omistajat',      'owners',           forms.EditIdeaOwnersForm,
     views.IdeaOwnerEditView),
    (r'aiheet',         'tags',             forms.EditInitiativeTagsForm),
    (r'organisaatiot',  'organizations',    forms.EditIdeaOrganizationsForm),
    (r'asetukset',      'settings',         forms.EditIdeaSettingsForm),
)
Пример #5
0
# coding=utf-8

from __future__ import unicode_literals

from django.conf.urls import patterns, url, include

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

from . import views
from .models import Survey, SurveyQuestion
from .perms import CanEditSurvey, CanAnswerSurvey, ShowSurveyResults

survey_as_obj = obj_by_pk(Survey, "survey_id")
question_as_obj = obj_by_pk(SurveyQuestion, "question_id")

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(
Пример #6
0
from libs.djcontrib.conf.urls import decorated_patterns
from libs.djcontrib.utils.decorators import combo, obj_by_pk
from libs.permitter.decorators import check_perm
from nkcomments.perms import CanEditComment

from nkvote.models import Vote

from . import views
from .models import CustomComment
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"))
Пример #7
0
from __future__ import unicode_literals

from django.conf.urls import url, patterns

from libs.djcontrib.utils.decorators import obj_by_pk
from libs.permitter.decorators import check_perm

from content.models import Initiative

from . import views
from .models import Gallup
from .perms import CanAnswerGallup, CanViewGallup, CanCreateGallup, CanDeleteGallup, \
    CanEditGallup, CanOpenGallup, CanCloseGallup


gallup_as_obj = obj_by_pk(Gallup, "gallup_id")
initiative_as_obj = obj_by_pk(Initiative, "initiative_id")

urlpatterns = patterns(
    "",
    url(
        r'^uusi/$',
        initiative_as_obj(check_perm(CanCreateGallup)(views.GallupFormView.as_view())),
        name='create'
    ),
    url(
        r'^(?P<gallup_id>\d+)/muokkaa/$',
        gallup_as_obj(check_perm(CanEditGallup)(views.GallupFormView.as_view())),
        name='edit'
    ),
    url(
Пример #8
0
from __future__ import unicode_literals

from django.conf.urls import url, patterns

from libs.djcontrib.utils.decorators import obj_by_pk
from libs.permitter.decorators import check_perm

from content.models import Initiative

from . import views
from .models import Gallup
from .perms import CanAnswerGallup, CanViewGallup, CanCreateGallup, CanDeleteGallup, \
    CanEditGallup, CanOpenGallup, CanCloseGallup

gallup_as_obj = obj_by_pk(Gallup, "gallup_id")
initiative_as_obj = obj_by_pk(Initiative, "initiative_id")

urlpatterns = patterns(
    "",
    url(r'^uusi/$',
        initiative_as_obj(
            check_perm(CanCreateGallup)(views.GallupFormView.as_view())),
        name='create'),
    url(r'^(?P<gallup_id>\d+)/muokkaa/$',
        gallup_as_obj(
            check_perm(CanEditGallup)(views.GallupFormView.as_view())),
        name='edit'),
    url(r'^(?P<gallup_id>\d+)/avaa/$',
        gallup_as_obj(
            check_perm(CanOpenGallup)(views.GallupStatusChangeView.as_view(
Пример #9
0
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 nuka.decorators import legacy_json_plaintext

from nuka.perms import IsAuthenticated, IsModerator

from . import views, forms
from .models import Organization
from .perms import CanViewOrganization, CanEditOrganization
from slug.decorators import slug_to_object
from slug.views import SlugRedirect

org_by_pk = obj_by_pk(Organization)
obj_by_slug = slug_to_object(Organization)

# TODO: DRY against content.urls, generic edit&detail view?

ORGANIZATION_FRAGMENT_URLS = (
    # (url part, template name/url name part, form_class)
    # (r'kuva',           'picture',          forms.EditOrganizationPictureForm),
    (r'kuvaus',         'description',      forms.EditOrganizationDescriptionForm),
    (r'yhteyshenkilot', 'admins',           forms.EditOrganizationAdminsForm),
    (r'nimi',           'name',             forms.EditOrganizationNameForm),
    (r'tyyppi',         'type',             forms.EditOrganizationTypeForm),
)

partial_detail_urls = [
    url(r'(?P<pk>\d+)/nayta/%s/$' % u[0],
Пример #10
0
     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'),
Пример #11
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'))
Пример #12
0
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'
    )
)
Пример #13
0
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 nuka.decorators import legacy_json_plaintext

from nuka.perms import IsAuthenticated, IsModerator

from . import views, forms
from .models import Organization
from .perms import CanViewOrganization, CanEditOrganization
from slug.decorators import slug_to_object
from slug.views import SlugRedirect

org_by_pk = obj_by_pk(Organization)
obj_by_slug = slug_to_object(Organization)

# TODO: DRY against content.urls, generic edit&detail view?

ORGANIZATION_FRAGMENT_URLS = (
    # (url part, template name/url name part, form_class)
    # (r'kuva',           'picture',          forms.EditOrganizationPictureForm),
    (r'kuvaus', 'description', forms.EditOrganizationDescriptionForm),
    (r'yhteyshenkilot', 'admins', forms.EditOrganizationAdminsForm),
    (r'nimi', 'name', forms.EditOrganizationNameForm),
    (r'tyyppi', 'type', forms.EditOrganizationTypeForm),
)

partial_detail_urls = [
    url(r'(?P<pk>\d+)/nayta/%s/$' % u[0],
Пример #14
0
from content.perms import CanCommentInitiative

from libs.djcontrib.conf.urls import decorated_patterns
from libs.djcontrib.utils.decorators import combo, obj_by_pk
from libs.permitter.decorators import check_perm
from nkcomments.perms import CanEditComment

from nkvote.models import Vote

from . import views
from .models import CustomComment
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),
Пример #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')
)