def send_alert(from_user, sub_group, message, subject): """ Send an alert through all methods for sub_group. """ # Validate permissions if not sub_group.get_user_perms(from_user)[0]: raise AttributeError("User does not have broadcast permissions.") else: # Build list of users who are eligible to recieve alerts to_list = [] if not method_registry.registry: method_registry.autodiscover() for user in User.objects.filter(is_active=True): if user.has_perm('Alerts.can_alert'): to_list.append(user) for method in method_registry.registry: method_registry.registry[method]().send_alert(to_list, subject, message, from_user, sub_group) return method_registry.registry
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from django.conf.urls import patterns, include, url # Run the autodiscovers for various registries to fill them from search import registry as search_registry from Alerts import method_registry from core import admin_page_registry, nav_registry # Uncomment to enable django admin #from django.contrib import admin #admin.autodiscover() method_registry.autodiscover() search_registry.autodiscover() admin_page_registry.autodiscover() nav_registry.autodiscover() # Actual URL definitions urlpatterns = patterns('', # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^$', 'core.views.home_view', name='index'), # Uncommend to enable django admin #url(r'^admin/', include(admin.site.urls)), url(r'^settings/$', 'core.views.config_view', name='settings'), url(r'^account/', include('account.urls')), url(r'^map/', include('Map.urls')), url(r'^search/', include('search.urls')),
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from django.conf.urls import patterns, include, url # Run the autodiscovers for various registries to fill them from search import registry as search_registry from Alerts import method_registry from core import admin_page_registry, nav_registry # Uncomment to enable django admin #from django.contrib import admin #admin.autodiscover() method_registry.autodiscover() search_registry.autodiscover() admin_page_registry.autodiscover() nav_registry.autodiscover() # Actual URL definitions urlpatterns = patterns( '', # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^$', 'core.views.home_view', name='index'), # Uncommend to enable django admin #url(r'^admin/', include(admin.site.urls)), url(r'^settings/$', 'core.views.config_view', name='settings'), url(r'^account/', include('account.urls')), url(r'^map/', include('Map.urls')),