=== removed directory 'lava_projects'
=== removed file 'lava_projects/__init__.py'
@@ -1,19 +0,0 @@
-# Copyright (C) 2010, 2011 Linaro Limited
-#
-# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
-#
-# This file is part of LAVA Server.
-#
-# LAVA Server is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License version 3
-# as published by the Free Software Foundation
-#
-# LAVA Server is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with LAVA Server. If not, see <http://www.gnu.org/licenses/>.
-
-__version__ = (0, 1, 0, "final", 0)
=== removed file 'lava_projects/admin.py'
@@ -1,38 +0,0 @@
-# Copyright (C) 2010, 2011 Linaro Limited
-#
-# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
-#
-# This file is part of LAVA Server.
-#
-# LAVA Server is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License version 3
-# as published by the Free Software Foundation
-#
-# LAVA Server is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with LAVA Server. If not, see <http://www.gnu.org/licenses/>.
-
-from django.contrib import admin
-
-from lava_projects.models import Project, ProjectFormerIdentifier
-
-
-class ProjectAdmin(admin.ModelAdmin):
-
- list_display = (
- '__unicode__', 'identifier', 'registered_by',
- 'registered_on', 'is_public', 'owner')
-
-
-class ProjectFormerIdentifierAdmin(admin.ModelAdmin):
-
- list_display = (
- 'former_identifier', 'project', 'renamed_on', 'renamed_by')
-
-
-admin.site.register(Project, ProjectAdmin)
-admin.site.register(ProjectFormerIdentifier, ProjectFormerIdentifierAdmin)
=== removed file 'lava_projects/extension.py'
@@ -1,48 +0,0 @@
-# Copyright (C) 2010, 2011 Linaro Limited
-#
-# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
-#
-# This file is part of LAVA Server.
-#
-# LAVA Server is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License version 3
-# as published by the Free Software Foundation
-#
-# LAVA Server is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with LAVA Server. If not, see <http://www.gnu.org/licenses/>.
-
-from lava_server.extension import LavaServerExtension
-
-
-class ProjectExtension(LavaServerExtension):
- """
- Extension adding project support
- """
-
- @property
- def app_name(self):
- return "lava_projects"
-
- @property
- def name(self):
- return "Projects"
-
- @property
- def main_view_name(self):
- return "lava.project.root"
-
- @property
- def description(self):
- return "Project support for LAVA"
-
- @property
- def version(self):
- import lava_projects
- import versiontools
- return versiontools.format_version(
- lava_projects.__version__, hint=lava_projects)
=== removed file 'lava_projects/forms.py'
@@ -1,179 +0,0 @@
-# Copyright (C) 2010, 2011 Linaro Limited
-#
-# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
-#
-# This file is part of LAVA Server.
-#
-# LAVA Server is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License version 3
-# as published by the Free Software Foundation
-#
-# LAVA Server is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with LAVA Server. If not, see <http://www.gnu.org/licenses/>.
-
-from django import forms
-from django.contrib.auth.models import Group
-from django.core.exceptions import ValidationError
-from django.utils.translation import ugettext as _
-
-from lava_projects.models import Project
-
-
-class _ProjectForm(forms.Form):
- """
- Mix-in with common project fields.
- """
-
- name = forms.CharField(
- label=_(u"Projet name"),
- help_text=_(u"Any name of your liking, can be updated later if you"
- u" change your mind"),
- required=True,
- max_length=100)
-
- description = forms.CharField(
- label=_(u"Description"),
- help_text=_(u"Arbitrary text about the project, you can use markdown"
- u" formatting to style it"),
- widget=forms.widgets.Textarea(),
- required=False)
-
- group = forms.ModelChoiceField(
- label=_(u"Group owner"),
- help_text=_(u"Members of the selected group will co-own this project"),
- empty_label=_("None, I'll be the owner"),
- required=False,
- queryset=Group.objects.all())
-
- is_public = forms.BooleanField(
- label=_(u"Project is public"),
- help_text=_(u"If selected then this project will be visible to anyone."
- u" Otherwise only owners can see the project"),
- required=False)
-
- is_aggregate = forms.BooleanField(
- label=_(u"Project is an aggregation (distribution)"),
- help_text=_(u"If selected the project will be treated like a"
- u" distribution. Some UI elements are optimized for that"
- u" case and behave differently."),
- required=False)
-
- def restrict_group_selection_for_user(self, user):
- assert user is not None
- self.fields['group'].queryset = user.groups.all()
-
-
-class ProjectRegistrationForm(_ProjectForm):
- """
- Form for registering new projects.
- """
-
- identifier = forms.CharField(
- label=_(u"Identifier"),
- help_text=_(u"A unique identifier built from restricted subset of"
- u" characters (only basic lowercase letters, numbers and"
- u" dash)"),
- required=True,
- max_length=100)
-
- def __init__(self, *args, **kwargs):
- super(ProjectRegistrationForm, self).__init__(*args, **kwargs)
- self._reorder_fields(['name', 'identifier'])
-
- def _reorder_fields(self, first):
- for field in reversed(first):
- self.fields.keyOrder.remove(field)
- self.fields.keyOrder.insert(0, field)
-
- def clean_identifier(self):
- """
- Check that the identifier is correct:
-
- 1) It does not collide with other projects
- 2) Or their past identifiers
- """
- value = self.cleaned_data['identifier']
- try:
- # Lookup project that is, or was, this identifier
- project = Project.objects.all().get_by_identifier(value)
- if project.identifier == value:
- # Disallow current identifiers from other projects
- raise ValidationError(
- "Project {0} is already using this identifier".format(
- project))
- else:
- # Disallow past identifiers from other projects
- raise ValidationError(
- "Project {0} was using this identifier in the past".format(
- project))
- except Project.DoesNotExist:
- pass
- return value
-
-
-class ProjectUpdateForm(_ProjectForm):
- """
- Form for updating project data
- """
-
-
-class ProjectRenameForm(forms.Form):
- """
- Form for changing the project identifier
- """
-
- name = forms.CharField(
- label=_(u"Projet name"),
- help_text=_(u"The new project name, same limits as before "
- u"(100 chars)"),
- required=True,
- max_length=100)
-
- identifier = forms.CharField(
- label=_(u"New identifier"),
- help_text=_(u"The new identifier has to be different from any current"
- u" or past identifier used by other projects."),
- required=True,
- max_length=100)
-
- def __init__(self, project, *args, **kwargs):
- super(ProjectRenameForm, self).__init__(*args, **kwargs)
- self.project = project
-
- def clean_identifier(self):
- """
- Check that new identifier is correct:
-
- 1) It does not collide with other projects
- 2) Or their past identifiers
- 3) It is different than the one we are currently using
- """
- value = self.cleaned_data['identifier']
- try:
- # Lookup project that is, or was, using this identifier
- project = Project.objects.all().get_by_identifier(value)
- if project == self.project and project.identifier != value:
- # Allow reusing identifiers inside one project
- pass
- elif project == self.project and project.identifier == value:
- raise ValidationError(
- _(u"The new identifier has to be different than the one"
- u"you are currently using"))
- elif project.identifier == value:
- # Disallow current identifiers from other projects
- raise ValidationError(
- _(u"Project {0} is already using this identifier").format(
- project))
- else:
- # Disallow past identifiers from other projects
- raise ValidationError(
- _(u"Project {0} was using this identifier in the"
- u"past").format(project))
- except Project.DoesNotExist:
- pass
- return value
=== removed directory 'lava_projects/migrations'
=== removed file 'lava_projects/migrations/0001_add_model_Project.py'
@@ -1,91 +0,0 @@
-# encoding: utf-8
-import datetime
-from south.db import db
-from south.v2 import SchemaMigration
-from django.db import models
-
-class Migration(SchemaMigration):
-
- def forwards(self, orm):
-
- # Adding model 'Project'
- db.create_table('lava_projects_project', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
- ('group', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.Group'], null=True, blank=True)),
- ('is_public', self.gf('django.db.models.fields.BooleanField')(default=False)),
- ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
- ('identifier', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=100, db_index=True)),
- ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
- ('is_aggregate', self.gf('django.db.models.fields.BooleanField')(default=False)),
- ('registered_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='projects', to=orm['auth.User'])),
- ('registered_on', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
- ))
- db.send_create_signal('lava_projects', ['Project'])
-
-
- def backwards(self, orm):
-
- # Deleting model 'Project'
- db.delete_table('lava_projects_project')
-
-
- models = {
- 'auth.group': {
- 'Meta': {'object_name': 'Group'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
- 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
- },
- 'auth.permission': {
- 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
- 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- },
- 'auth.user': {
- 'Meta': {'object_name': 'User'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
- 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
- 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
- },
- 'contenttypes.contenttype': {
- 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
- 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
- },
- 'lava_projects.project': {
- 'Meta': {'object_name': 'Project'},
- 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.Group']", 'null': 'True', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'identifier': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}),
- 'is_aggregate': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'registered_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects'", 'to': "orm['auth.User']"}),
- 'registered_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
- 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
- },
- 'lava_projects.projectfomeridentifier': {
- 'Meta': {'object_name': 'ProjectFomerIdentifier'},
- 'former_identifier': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'former_identifiers'", 'to': "orm['lava_projects.Project']"})
- }
- }
-
- complete_apps = ['lava_projects']
=== removed file 'lava_projects/migrations/0002_add_model_ProjectFormerIdentifier.py'
@@ -1,88 +0,0 @@
-# encoding: utf-8
-import datetime
-from south.db import db
-from south.v2 import SchemaMigration
-from django.db import models
-
-class Migration(SchemaMigration):
-
- def forwards(self, orm):
-
- # Adding model 'ProjectFormerIdentifier'
- db.create_table('lava_projects_projectformeridentifier', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('project', self.gf('django.db.models.fields.related.ForeignKey')(related_name='former_identifiers', to=orm['lava_projects.Project'])),
- ('former_identifier', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=100, db_index=True)),
- ('renamed_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='project_former_identifiers_created', to=orm['auth.User'])),
- ('renamed_on', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
- ))
- db.send_create_signal('lava_projects', ['ProjectFormerIdentifier'])
-
-
- def backwards(self, orm):
-
- # Deleting model 'ProjectFormerIdentifier'
- db.delete_table('lava_projects_projectformeridentifier')
-
-
- models = {
- 'auth.group': {
- 'Meta': {'object_name': 'Group'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
- 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
- },
- 'auth.permission': {
- 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
- 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- },
- 'auth.user': {
- 'Meta': {'object_name': 'User'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
- 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
- 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
- },
- 'contenttypes.contenttype': {
- 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
- 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
- },
- 'lava_projects.project': {
- 'Meta': {'object_name': 'Project'},
- 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.Group']", 'null': 'True', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'identifier': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}),
- 'is_aggregate': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'registered_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects'", 'to': "orm['auth.User']"}),
- 'registered_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
- 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
- },
- 'lava_projects.projectformeridentifier': {
- 'Meta': {'object_name': 'ProjectFormerIdentifier'},
- 'former_identifier': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'former_identifiers'", 'to': "orm['lava_projects.Project']"}),
- 'renamed_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'project_former_identifiers_created'", 'to': "orm['auth.User']"}),
- 'renamed_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'})
- }
- }
-
- complete_apps = ['lava_projects']
=== removed file 'lava_projects/migrations/__init__.py'
=== removed file 'lava_projects/models.py'
@@ -1,168 +0,0 @@
-# Copyright (C) 2010, 2011 Linaro Limited
-#
-# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
-#
-# This file is part of LAVA Server.
-#
-# LAVA Server is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License version 3
-# as published by the Free Software Foundation
-#
-# LAVA Server is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with LAVA Server. If not, see <http://www.gnu.org/licenses/>.
-
-from django.contrib.auth.models import User
-from django.db import models
-from django.db.models.query import QuerySet
-from django.utils.translation import ugettext as _
-from django_restricted_resource.managers import RestrictedResourceManager
-from django_restricted_resource.models import RestrictedResource
-
-
-class ProjectQuerySet(QuerySet):
- """
- Query set with extra methods for projects
- """
-
- def recently_registered(self):
- return self.order_by("-registered_on")[:10]
-
- def get_by_identifier(self, identifier):
- """
- Get project by identifier, also searching for past
- identifiers (project renames)
- """
- try:
- return self.get(identifier=identifier)
- except Project.DoesNotExist as no_such_project:
- try:
- return ProjectFormerIdentifier.objects.get(
- former_identifier=identifier).project
- except ProjectFormerIdentifier.DoesNotExist:
- raise no_such_project
-
-
-class ProjectManager(RestrictedResourceManager):
- """
- Manager with custom query set for projects
- """
- use_for_related_fields = True
-
- def get_query_set(self):
- return ProjectQuerySet(self.model, using=self._db)
-
- def recently_registered(self):
- return self.get_query_set().recently_registered()
-
- def get_by_identifier(self, identifier):
- return self.get_query_set().get_by_identifier(identifier)
-
-
-class ProjectFormerIdentifier(models.Model):
- """
- Former identifier of a project. Allows users to change the project
- identifier while keeping URLs working properly.
- """
-
- project = models.ForeignKey(
- "Project",
- null=False,
- blank=False,
- verbose_name=_(u"Project"),
- related_name="former_identifiers")
-
- former_identifier = models.SlugField(
- null=False,
- blank=False,
- max_length=100,
- verbose_name=_(u"Former identifier"),
- help_text=_(u"A unique identifier built from restricted subset of"
- u" characters (only basic letters, numbers and dash)"),
- unique=True)
-
- renamed_by = models.ForeignKey(
- User,
- related_name="project_former_identifiers_created",
- blank=False,
- null=False,
- verbose_name=_(u"Renamed by"),
- help_text=_(u"User who renamed the project"))
-
- renamed_on = models.DateTimeField(
- auto_now_add=True,
- blank=False,
- null=False,
- verbose_name=_(u"Renamed on"),
- help_text=_(u"Date and time of rename operation"))
-
- def __unicode__(self):
- return self.former_identifier
-
-
-class Project(RestrictedResource):
- """
- Project is a container of everything else. Projects are restricted
- resources and thus belong to a particular user or group and have a "public"
- flag.
- """
-
- name = models.CharField(
- null=False,
- blank=False,
- max_length=100,
- verbose_name=_(u"Name"),
- help_text=_(u"Name (this is how your project will be displayed"
- u" throughout LAVA)"))
-
- identifier = models.SlugField(
- null=False,
- blank=False,
- max_length=100,
- verbose_name=_(u"Identifier"),
- help_text=_(u"A unique identifier built from restricted subset of"
- u" characters (only basic letters, numbers and dash)"),
- unique=True)
-
- description = models.TextField(
- null=False,
- blank=True,
- verbose_name=_(u"Description"),
- help_text=_(u"Arbitrary text about the project, you can use markdown"
- u" formatting to style it"))
-
- is_aggregate = models.BooleanField(
- blank=True,
- null=False,
- verbose_name=_(u"Aggregate"),
- help_text=_(u"When selected the project will be treated like a"
- u" distribution. Some UI elements are optimized for that"
- u" case and behave differently."))
-
- registered_by = models.ForeignKey(
- User,
- related_name="projects",
- blank=False,
- null=False,
- verbose_name=_(u"Registered by"),
- help_text=_(u"User who registered this project"))
-
- registered_on = models.DateTimeField(
- auto_now_add=True,
- blank=False,
- null=False,
- verbose_name=_(u"Registered on"),
- help_text=_(u"Date and time of registration"))
-
- objects = ProjectManager()
-
- def __unicode__(self):
- return self.name
-
- @models.permalink
- def get_absolute_url(self):
- return ('lava.project.detail', [self.identifier])
=== removed directory 'lava_projects/templates'
=== removed directory 'lava_projects/templates/lava_projects'
=== removed file 'lava_projects/templates/lava_projects/_project_actions.html'
@@ -1,5 +0,0 @@
-<h3>Actions</h3>
-<ul>
- <li><a href="{% url lava.project.list %}">Display a list of all projects</a></li>
- <li><a href="{% url lava.project.register %}">Register a new project</a></li>
-</ul>
=== removed file 'lava_projects/templates/lava_projects/_project_form.html'
@@ -1,19 +0,0 @@
-{% extends "layouts/form.html" %}
-
-
-{% block extrahead %}
-{{ block.super }}
-<script type="text/javascript" src="{{ STATIC_URL }}lava-server/js/jquery.slugify.js"></script>
-<script type="text/javascript" src="{{ STATIC_URL }}lava_markitup/jquery.markitup.js"></script>
-<script type="text/javascript" src="{{ STATIC_URL }}lava_markitup/sets/markdown/set.js"></script>
-<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}lava_markitup/skins/simple/style.css"/>
-<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}lava_markitup/sets/markdown/style.css"/>
-{% endblock %}
-
-
-{% block content %}
-<style type="text/css">
- iframe { border: 1px dotted #333; }
-</style>
-{{ block.super }}
-{% endblock %}
=== removed file 'lava_projects/templates/lava_projects/project_detail.html'
@@ -1,43 +0,0 @@
-{% extends "layouts/content_with_sidebar.html" %}
-{% load markup %}
-
-
-{% block sidebar %}
-{% include "lava_projects/_project_actions.html" %}
-{% if belongs_to_user %}
-<h3>Project administration</h3>
-<ul>
- <li><a href="{% url lava.project.update project.identifier %}">Update this project</a></li>
-</ul>
-{% endif %}
-{% endblock %}
-
-
-{% block content %}
-{% if former_identifier %}
-<div class="ui-state-highlight">
- <p><span
- class="ui-icon ui-icon-info"
- style="float: left; margin: 2pt"></span>
- This project was renamed to <strong>{{ project.identifier }}</strong>
- {{ former_identifier.renamed_on|timesince }} ago. The old URL referring to
- <strong>{{ former_identifier.former_identifier }}</strong> will redirect here
- automatically but you should update your bookmarks or hyper-links</p>
-</div>
-{% endif %}
-<h1>{{ project }}</h1>
-<p>
-{% if project.user == project.registered_by %}
-Owned and registered by {{ project.owner }} on {{ project.registered_on|date }}
-{% else %}
-Owned by {{ project.owner }}
-{% if project.group and belongs_to_user %}
-<em>(you are a member of this group)</em>
-{% endif %}
-, registered by {{ project.registered_by }} on {{ project.registered_on|date }}
-{% endif %}
-</p>
-<div class="project-description">
- {{ project.description|markdown }}
-</div>
-{% endblock %}
=== removed file 'lava_projects/templates/lava_projects/project_list.html'
@@ -1,19 +0,0 @@
-{% extends "layouts/content_with_sidebar.html" %}
-
-
-{% block sidebar %}
-{% include "lava_projects/_project_actions.html" %}
-{% endblock %}
-
-
-{% block content %}
-<h2>Existing projects</h2>
-<ul>
- {% for project in project_list %}
- <li>
- <a href="{{ project.get_absolute_url }}">{{ project }}</a>
- {% if not project.is_public %}<strong>(private)</strong>{% endif %}
- </li>
- {% endfor %}
-</ul>
-{% endblock %}
=== removed file 'lava_projects/templates/lava_projects/project_register_form.html'
@@ -1,18 +0,0 @@
-{% extends "lava_projects/_project_form.html" %}
-
-
-{% block form_header %}
-<h1>Register a project in LAVA</h1>
-{% endblock %}
-
-
-{% block form_footer %}
-{{ block.super }}
-<script type="text/javascript">
- mySettings.previewParserPath = "{% url lava.markitup.markdown %}";
- $(document).ready(function() {
- $("#id_identifier").slugify($("#id_name"));
- $("#id_description").markItUp(mySettings);
- });
-</script>
-{% endblock %}
=== removed file 'lava_projects/templates/lava_projects/project_rename_form.html'
@@ -1,35 +0,0 @@
-{% extends "lava_projects/_project_form.html" %}
-
-
-{% block form_header %}
-<h1>Rename {{ project }}</h1>
-<p>Renaming a project is always possible but should be done carefully.
-Each historic identifier is stored to ensure old URLs continue to work. They
-are also reserved to prevent new projects from using them.</p>
-{% endblock %}
-
-
-{% block form_field %}
-{% if field.name == "identifier" %}
-<tr>
- <th>Old identifier</th>
- <td>
- <input type="text" disabled="disabled" value="{{ project.identifier }}"></input>
- <p class='help_text'>This is your current project identifier</p>
- </td>
-</tr>
-{% endif %}
-{{ block.super }}
-{% endblock %}
-
-
-{% block form_footer %}
-<h2>Continue</h2>
-<input type="submit" value="Save"/> or <a href="{{ project.get_absolute_url }}">cancel</a>
-<script type="text/javascript">
- $(document).ready(function() {
- // Remove existing value, enable slugify helper
- $("#id_identifier").val("").slugify($("#id_name"));
- });
-</script>
-{% endblock %}
=== removed file 'lava_projects/templates/lava_projects/project_root.html'
@@ -1,30 +0,0 @@
-{% extends "layouts/content_with_sidebar.html" %}
-
-
-{% block sidebar %}
-{% include "lava_projects/_project_actions.html" %}
-{% endblock %}
-
-
-{% block content %}
-<h2>Projects</h2>
-<p>LAVA uses projects to organize other data structures. Projects are similar
-to the project concept in other development tools and web applications.</p>
-
-<p>Anyone is free to <a href="{% url lava.project.register %}">register a
- project</a> and use that to coordinate testing efforts.</p>
-
-{% if recent_project_list %}
-<h3>Recently registered projects</h3>
-<ul>
- {% for project in recent_project_list %}
- <li>
- <a href="{{ project.get_absolute_url }}">{{ project }}</a>,
- registered {{ project.registered_on|timesince }} ago
- {% if not project.is_public %}<strong>(private)</strong>{% endif %}
- </li>
- {% endfor %}
-</ul>
-<p><a href="{% url lava.project.list %}">See all projects</a></p>
-{% endif %}
-{% endblock %}
=== removed file 'lava_projects/templates/lava_projects/project_update_form.html'
@@ -1,33 +0,0 @@
-{% extends "lava_projects/_project_form.html" %}
-
-
-{% block form_header %}
-<h1>Update {{ project }}</h1>
-{% endblock %}
-
-
-{% block form_field %}
-{{ block.super }}
-{% if field.name == "name" %}
-<tr>
- <th>Identifier<br/><small>(read only)</small></th>
- <td>
- <input type="text" disabled="disabled" value="{{ project.identifier }}"></input>
- <p class='help_text'>
- <a href="{% url lava.project.rename project.identifier %}">Rename this project</a> if you wish to change the identifier</p>
- </td>
-</tr>
-{% endif %}
-{% endblock %}
-
-
-{% block form_footer %}
-<h2>Continue</h2>
-<input type="submit" value="Save"/> or <a href="{{ project.get_absolute_url }}">cancel</a>
-<script type="text/javascript">
- mySettings.previewParserPath = "{% url lava.markitup.markdown %}";
- $(document).ready(function() {
- $("#id_description").markItUp(mySettings);
- });
-</script>
-{% endblock %}
=== removed file 'lava_projects/urls.py'
@@ -1,35 +0,0 @@
-# Copyright (C) 2010, 2011 Linaro Limited
-#
-# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
-#
-# This file is part of LAVA Server.
-#
-# LAVA Server is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License version 3
-# as published by the Free Software Foundation
-#
-# LAVA Server is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with LAVA Server. If not, see <http://www.gnu.org/licenses/>.
-
-from django.conf.urls.defaults import *
-
-
-urlpatterns = patterns(
- 'lava_projects.views',
- url('^$', 'project_root',
- name='lava.project.root'),
- url(r'^\+list/$', 'project_list',
- name='lava.project.list'),
- url(r'^\+register/$', 'project_register',
- name='lava.project.register'),
- url(r'^(?P<identifier>[a-z0-9-]+)/$', 'project_detail',
- name='lava.project.detail'),
- url(r'^(?P<identifier>[a-z0-9-]+)/\+update/$', 'project_update',
- name='lava.project.update'),
- url(r'^(?P<identifier>[a-z0-9-]+)/\+rename/$', 'project_rename',
- name='lava.project.rename'))
=== removed file 'lava_projects/views.py'
@@ -1,219 +0,0 @@
-# Copyright (C) 2010, 2011 Linaro Limited
-#
-# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
-#
-# This file is part of LAVA Server.
-#
-# LAVA Server is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License version 3
-# as published by the Free Software Foundation
-#
-# LAVA Server is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with LAVA Server. If not, see <http://www.gnu.org/licenses/>.
-
-from django.contrib.auth.decorators import login_required
-from django.http import (
- Http404,
- HttpResponse,
- HttpResponseForbidden,
- HttpResponseRedirect,
-)
-from django.shortcuts import get_object_or_404
-from django.template import RequestContext, loader
-from django.utils.translation import ugettext as _
-from django.views.generic.list_detail import object_list
-
-from lava_server.views import index as lava_index
-from lava_server.bread_crumbs import (
- BreadCrumb,
- BreadCrumbTrail,
-)
-from lava_projects.models import (
- Project,
- ProjectFormerIdentifier,
-)
-from lava_projects.forms import (
- ProjectRenameForm,
- ProjectRegistrationForm,
- ProjectUpdateForm,
-)
-
-
-@BreadCrumb(_("Projects"), parent=lava_index)
-def project_root(request):
- template_name = "lava_projects/project_root.html"
- t = loader.get_template(template_name)
- c = RequestContext(request, {
- 'recent_project_list': Project.objects.accessible_by_principal(
- request.user).recently_registered(),
- 'bread_crumb_trail': BreadCrumbTrail.leading_to(project_root)})
- return HttpResponse(t.render(c))
-
-
-@BreadCrumb(_("List of all projects"), project_root)
-def project_list(request):
- return object_list(
- request,
- queryset=Project.objects.accessible_by_principal(request.user),
- template_name="lava_projects/project_list.html",
- extra_context={
- 'bread_crumb_trail': BreadCrumbTrail.leading_to(
- project_list)},
- template_object_name="project")
-
-
-@BreadCrumb("{project}",
- parent=project_root,
- needs=['project_identifier'])
-def project_detail(request, identifier):
- # A get by identifier, looking at renames, if needed.
- try:
- project = Project.objects.accessible_by_principal(
- request.user).get_by_identifier(identifier)
- except Project.DoesNotExist:
- raise Http404("No such project")
- # Redirect users to proper URL of this project if using one of the older
- # names.
- if project.identifier != identifier:
- return HttpResponseRedirect(
- project.get_absolute_url() + "?former_identifier=" + identifier)
- # Lookup former identifier if we have been redirected
- former_identifier = None
- if request.GET.get("former_identifier"):
- try:
- former_identifier = ProjectFormerIdentifier.objects.get(
- former_identifier=request.GET.get("former_identifier"))
- except ProjectFormerIdentifier.DoesNotExist:
- pass
- # Render to template
- template_name = "lava_projects/project_detail.html"
- t = loader.get_template(template_name)
- c = RequestContext(request, {
- 'project': project,
- 'former_identifier': former_identifier,
- 'belongs_to_user': project.is_owned_by(request.user),
- 'bread_crumb_trail': BreadCrumbTrail.leading_to(
- project_detail,
- project=project,
- project_identifier=project.identifier)})
- return HttpResponse(t.render(c))
-
-
-@BreadCrumb(_("Register new project"),
- parent=project_root)
-@login_required
-def project_register(request):
- if request.method == 'POST':
- form = ProjectRegistrationForm(request.POST, request.FILES)
- form.restrict_group_selection_for_user(request.user)
- # Check the form
- if form.is_valid():
- # And make a project instance
- project = Project.objects.create(
- name=form.cleaned_data['name'],
- identifier=form.cleaned_data['identifier'],
- description=form.cleaned_data['description'],
- is_aggregate=form.cleaned_data['is_aggregate'],
- owner=form.cleaned_data['group'] or request.user,
- is_public=form.cleaned_data['is_public'],
- registered_by=request.user)
- return HttpResponseRedirect(project.get_absolute_url())
- else:
- form = ProjectRegistrationForm()
- # Render to template
- template_name = "lava_projects/project_register_form.html"
- t = loader.get_template(template_name)
- c = RequestContext(request, {
- 'form': form,
- 'bread_crumb_trail': BreadCrumbTrail.leading_to(project_register),
- })
- return HttpResponse(t.render(c))
-
-
-@BreadCrumb(_("Reconfigure"),
- parent=project_detail,
- needs=['project_identifier'])
-@login_required
-def project_update(request, identifier):
- project = get_object_or_404(
- Project.objects.accessible_by_principal(request.user),
- identifier=identifier)
- if not project.is_owned_by(request.user):
- return HttpResponseForbidden("You cannot update this project")
- if request.method == 'POST':
- form = ProjectUpdateForm(request.POST, request.FILES)
- form.restrict_group_selection_for_user(request.user)
- if form.is_valid():
- project.name = form.cleaned_data['name']
- project.description = form.cleaned_data['description']
- project.is_aggregate = form.cleaned_data['is_aggregate']
- project.owner = form.cleaned_data['group'] or request.user
- project.is_public = form.cleaned_data['is_public']
- project.save()
- return HttpResponseRedirect(project.get_absolute_url())
- else:
- form = ProjectUpdateForm(initial=dict(
- name=project.name,
- description=project.description,
- is_aggregate=project.is_aggregate,
- group=project.group,
- is_public=project.is_public))
- template_name = "lava_projects/project_update_form.html"
- t = loader.get_template(template_name)
- c = RequestContext(request, {
- 'form': form,
- 'project': project,
- 'bread_crumb_trail': BreadCrumbTrail.leading_to(
- project_update,
- project=project,
- project_identifier=project.identifier)})
- return HttpResponse(t.render(c))
-
-
-@BreadCrumb(_("Change identifier"),
- parent=project_update,
- needs=['project_identifier'])
-@login_required
-def project_rename(request, identifier):
- project = get_object_or_404(
- Project.objects.accessible_by_principal(request.user),
- identifier=identifier)
- if not project.is_owned_by(request.user):
- return HttpResponseForbidden("You cannot update this project")
- if request.method == 'POST':
- form = ProjectRenameForm(project, request.POST)
- if form.is_valid():
- # Remove old entry if we are reusing our older identifier
- ProjectFormerIdentifier.objects.filter(
- former_identifier=form.cleaned_data['identifier'],
- project=project.pk).delete()
- # Record the change taking place
- ProjectFormerIdentifier.objects.create(
- project=project,
- former_identifier=project.identifier,
- renamed_by=request.user)
- # And update the project
- project.name = form.cleaned_data['name']
- project.identifier = form.cleaned_data['identifier']
- project.save()
- return HttpResponseRedirect(project.get_absolute_url())
- else:
- form = ProjectRenameForm(
- project, initial={
- 'name': project.name,
- 'identifier': project.identifier})
- template_name = "lava_projects/project_rename_form.html"
- t = loader.get_template(template_name)
- c = RequestContext(request, {
- 'form': form,
- 'project': project,
- 'bread_crumb_trail': BreadCrumbTrail.leading_to(
- project_rename,
- project=project,
- project_identifier=project.identifier)})
- return HttpResponse(t.render(c))
=== modified file 'setup.py'
@@ -33,8 +33,6 @@
lava-server = lava_server.manage:main
[lava_server.commands]
manage=lava_server.manage:manage
- [lava_server.extensions]
- project=lava_projects.extension:ProjectExtension
""",
test_suite="lava_server.tests.run_tests",
license="AGPL",