1. Daniel Greenfeld
  2. transifex

Commits

Diego Búrigo Zacarão  committed 4c7f4ff

Improved URL structure (#298)

- It was needed because some slugs of some objects could match
with an action in the url.
- From now on Tx uses the following structure:
- <app_name>/<type_obj>/<obj_slug>/<action>
- <app_name>/<action>
- Examples:
- /projects/transifex/ -> /projects/p/transifex/
- /projects/transifex/default -> /projects/p/transifex/c/default
- /languages/pt_BR -> /languages/l/pt_BR/

  • Participants
  • Parent commits 26500db
  • Branches default

Comments (0)

Files changed (3)

File transifex/languages/urls.py

View file
         kwargs = {'feed_dict': feeds,
                   'slug': 'all'}),
     url(
-        regex = '^(?P<language_slug>[-_@\w]+)/collection/(?P<collection_slug>[-\w]+)/(?P<release_slug>[-\w]+)/feed/$',
+        regex = '^l/(?P<language_slug>[-_@\w]+)/collection/c/(?P<collection_slug>[-\w]+)/r/(?P<release_slug>[-\w]+)/feed/$',
         view = language_release_feed,
         name = 'language_release_feed',
         kwargs = {'feed_dict': feeds,
     ),
     url(
         name = 'language_detail',
-        regex = '^(?P<slug>[-_@\w]+)/$',
+        regex = '^l/(?P<slug>[-_@\w]+)/$',
         view = language_detail,
         kwargs = {'slug_field': 'code',
                   "template_object_name" : "language",
     ),
     url(
         name = 'language_release',
-        regex = '^(?P<slug>[-_@\w]+)/collection/(?P<collection_slug>[-\w]+)/(?P<release_slug>[-\w]+)/$',
+        regex = '^l/(?P<slug>[-_@\w]+)/collection/c/(?P<collection_slug>[-\w]+)/r/(?P<release_slug>[-\w]+)/$',
         view = language_release,
     ),
 )
     urlpatterns += patterns('',
         url(
             name = 'language_release_download',
-            regex = '^(?P<slug>[-_@\w]+)/collection/(?P<collection_slug>[-\w]+)/(?P<release_slug>[-\w]+)/download_(?P<filetype>[\w]+)/$',
+            regex = '^l/(?P<slug>[-_@\w]+)/collection/c/(?P<collection_slug>[-\w]+)/r/(?P<release_slug>[-\w]+)/download_(?P<filetype>[\w]+)/$',
             view = language_release_download,
         ),
 )

File transifex/projects/urls.py

View file
         view = project_create,
         name = 'project_create'),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/edit/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/edit/$',
         view = project_update,
         name = 'project_edit',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/delete/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/delete/$',
         view = project_delete,
         name = 'project_delete',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/access/permission/add/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/access/pm/add/$',
         view = project_add_permission,
         name = 'project_add_permission'),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/access/permission/(?P<permission_pk>\d+)/delete/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/access/pm/(?P<permission_pk>\d+)/delete/$',
         view = project_delete_permission,
         name = 'project_delete_permission'),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/access/request/add/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/access/rq/add/$',
         view = project_add_permission_request,
         name = 'project_add_permission_request'),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/access/request/(?P<permission_pk>\d+)/delete/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/access/rq/(?P<permission_pk>\d+)/delete/$',
         view = project_delete_permission_request,
         name = 'project_delete_permission_request'),
         
-    url(regex = '^(?P<project_slug>[-\w]+)/access/request/(?P<permission_pk>\d+)/approve/$',
+    url(regex = '^p/(?P<project_slug>[-\w]+)/access/rq/(?P<permission_pk>\d+)/approve/$',
         view = project_approve_permission_request,
         name = "project_approve_permission_request"),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/toggle_watch/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/toggle_watch/$',
         view = project_toggle_watch,
         name = 'project_toggle_watch',),
 )
 
 urlpatterns += patterns('django.views.generic',
     url(
-        regex = '^(?P<slug>[-\w]+)/$',
+        regex = '^p/(?P<slug>[-\w]+)/$',
         view = 'list_detail.object_detail',
         name = 'project_detail',
         kwargs = project_list,),
 # Components
 urlpatterns += patterns('',
     url(
-        regex = '^(?P<project_slug>[-\w]+)/add-component/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/add-component/$',
         view = component_create_update,
         name = 'component_create',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/edit/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/edit/$',
         view = component_create_update,
         name = 'component_edit',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/delete/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/delete/$',
         view = component_delete,
         name = 'component_delete',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/clear_cache/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/clear_cache/$',
         view = component_clear_cache,
         name = 'component_clear_cache',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/set_stats/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/set_stats/$',
         view = component_set_stats,
         name = 'component_set_stats',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/raw/(?P<filename>(.*))$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/raw/(?P<filename>(.*))$',
         view = component_file,
         name = 'component_raw_file',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/view/(?P<filename>(.*))$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/view/(?P<filename>(.*))$',
         view = component_file,
         name = 'component_view_file',
         kwargs = {'view': True },),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/toggle_lock/(?P<filename>(.*))$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/toggle_lock/(?P<filename>(.*))$',
         view = component_toggle_lock_file,
         name = 'component_toggle_lock_file',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/submit/(?P<filename>(.*))$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/submit/(?P<filename>(.*))$',
         view = component_submit_file,
         name = 'component_submit_file',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/toggle_watch/pofile/(?P<filename>(.*))$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/toggle_watch/pofile/(?P<filename>(.*))$',
         view = component_toggle_watch,
         name = 'component_toggle_watch',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/submit/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/submit/$',
         view = component_submit_file,
         name = 'component_submit_new_file',),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/l/(?P<language_code>(.*))$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/l/(?P<language_code>(.*))$',
         view = component_language_detail,
         name = 'component_language_detail',),
     url (
-        regex = '^(?P<slug>[-\w]+)/component-added/$',
+        regex = '^p/(?P<slug>[-\w]+)/component-added/$',
         view = 'django.views.generic.list_detail.object_detail',
         kwargs = {'object_list': project_list,
                   'message': 'Component added.' },
         name = 'component_created'),
     url(
-        regex = '^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/$',
+        regex = '^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/$',
         view = component_detail,
         name = 'component_detail'),
 )
 if getattr(settings, 'ENABLE_WEBTRANS', True):
     urlpatterns += patterns('',
         url(
-            regex = ('^(?P<project_slug>[-\w]+)/(?P<component_slug>[-\w]+)/'
+            regex = ('^p/(?P<project_slug>[-\w]+)/c/(?P<component_slug>[-\w]+)/'
                     'edit/(?P<filename>(.*))$'),
             view = component_file_edit,
             name = 'component_edit_file',),

File transifex/txcollections/urls.py

View file
         name = 'collection_create',
         kwargs = {'model': Collection}),
     url(
-        regex = '^(?P<slug>[-\w]+)/edit/$',
+        regex = '^c/(?P<slug>[-\w]+)/edit/$',
         view = limited_update_object,
         name = 'collection_edit',
         kwargs = {'model': Collection,
                   'template_object_name': 'collection',}),
     url(
-        regex = '^(?P<slug>[-\w]+)/delete/$',
+        regex = '^c/(?P<slug>[-\w]+)/delete/$',
         view = collection_delete,
         name = 'collection_delete',
         kwargs = {'model': Collection,
                   'template_object_name': 'collection',}),
     url(
-        regex = '^(?P<slug>[-\w]+)/$',
+        regex = '^c/(?P<slug>[-\w]+)/$',
         view = 'list_detail.object_detail',
         name = 'collection_detail',
         kwargs = collection_list,),
         kwargs = {'feed_dict': feeds,
                   'slug': 'latest'}),
     url(
-        regex = r'^(?P<param>[-\w]+)/releases/feed/$',
+        regex = r'^c/(?P<param>[-\w]+)/releases/feed/$',
         view = SLUG_FEED,
         name = 'collection_feed',
         kwargs = {'feed_dict': feeds,
                   'slug': 'collection'}),
     url(
-        regex = '^(?P<collection_slug>[-\w]+)/(?P<release_slug>[-\w]+)/feed/$',
+        regex = '^c/(?P<collection_slug>[-\w]+)/r/(?P<release_slug>[-\w]+)/feed/$',
         view = release_languages_feed,
         name = 'release_languages_feed',
         kwargs = {'feed_dict': feeds,
 
 urlpatterns += patterns('',
     url(
-        regex = '^(?P<slug>[-\w]+)/add-release/$',
+        regex = '^c/(?P<slug>[-\w]+)/add-release/$',
         view = release_create_update,
         name = 'collection_release_create',
         kwargs = {'model': Release,}),
     url(
-        regex = '^(?P<slug>[-\w]+)/(?P<release_slug>[-\w]+)/edit/$',
+        regex = '^c/(?P<slug>[-\w]+)/r/(?P<release_slug>[-\w]+)/edit/$',
         view = release_create_update,
         name = 'collection_release_edit',
         kwargs = {'model': Release,
                   'template_object_name': 'release'}),
     url(
-        regex = '^(?P<collection_slug>[-\w]+)/(?P<release_slug>[-\w]+)/delete/$',
+        regex = '^c/(?P<collection_slug>[-\w]+)/r/(?P<release_slug>[-\w]+)/delete/$',
         view = collection_release_delete,
         name = 'collection_release_delete',),
 
     url (
-        regex = '^(?P<slug>[-\w]+)/release-added/$',
+        regex = '^c/(?P<slug>[-\w]+)/release-added/$',
         view = 'django.views.generic.list_detail.object_detail',
         name = 'collection_release_created',
         kwargs = {'object_list': collection_list,
                   'message': 'Component added.' },),
     url(
-        regex = '^(?P<slug>[-\w]+)/(?P<release_slug>[-\w]+)/$',
+        regex = '^c/(?P<slug>[-\w]+)/r/(?P<release_slug>[-\w]+)/$',
         view = release_detail,
         name = 'collection_release_detail',
         kwargs = {'template_object_name': 'release',