Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom domain #635

Merged
merged 9 commits into from
Jan 9, 2018
Merged

add custom domain #635

merged 9 commits into from
Jan 9, 2018

Conversation

anitanh
Copy link
Contributor

@anitanh anitanh commented Nov 29, 2017

fix #570 and fix #603

[ WIP ]

This PR:

  • created custom domain model where subscribed user and user domain is saved
  • when the user and domain are approved, it will write the user domain to server-name.txt which is included in nginx so the domain will be included in the allowed hosts.

@timlinux and @cchristelis is this the right approach?

in the admin panel:
screenshot from 2017-11-29 18-03-07
screenshot from 2017-11-29 18-03-20

)


class CustomDomain(models.Model):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just call it 'Domain' and then create a Domain entry for e.g. http://projecta.kartoza.com which is the default domain that all new projects get added to that do not have an explicitly set domain. Then add a foreign key reference to Domain from both the organisation and project models.

@@ -20,6 +20,7 @@ server {
# the domain name it will serve for
server_name staging.projecta.kartoza.com changelog.linfiniti.com changelog.kartoza.com changelog.qgis.org changelog.inasafe.org staging.changelog.qgis.org;
charset utf-8;
include /home/web/media/server-name.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would imaging that since we will on a dedicated server using * for server name might be a simpler approach and then let projecta handle whether the hostname in the header of the request if valid or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(that we we do not need to use server-name.txt tricks)


class Meta:
ordering = ['user']
unique_together = ['user', 'custom_domain']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the domain would need to be independently unique - otherwise what will happen if two users try to register the same domain?

)

class Meta:
ordering = ['user']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets order by the domain name

@timlinux
Copy link
Contributor

timlinux commented Dec 2, 2017

@Ann26 Referring back to my original ticket at #635 I think it makes more sense to make an atomic PR that adds an organisation model and associates each project with each organisation. By default we can associate projects with the 'global' organisation until the are assigned to a specific organisation.

Then each organisation and project will get associated with a domain.

@timlinux
Copy link
Contributor

timlinux commented Dec 3, 2017

@Ann26 can you also take a look at this PR from @meomancer and review whether the code will fit within the framework we are setting up here:

#361

@anitanh
Copy link
Contributor Author

anitanh commented Dec 20, 2017

ok @timlinux will do

@anitanh
Copy link
Contributor Author

anitanh commented Dec 21, 2017

Hi @timlinux , looking at @meomancer 's PR (#361) I think the code can fit our framework with a bit of modification.

I tried it in my local and using it we can assign additional administrators that can have permissions the same as the owner in the project, as shown below: (for staff users, they get all projects)
screenshot from 2017-12-21 20-35-16
So in above example case, I am (not a staff) the owner of Inasafe project and an administrator of XProject project. I have the same permissions as the owner of XProject eventhough I am not the owner of it.

The app also includes custom template tag that we can implement in template, e.g. the_project|is_project_administrator:user

Maybe the Project Collaborators can be the Managers of each app (e.g. changelog, sponsorship, certification) ?

In conclusion,

  • I think using permission app, we can manage permissions separately from the project model
  • Its custom template tag can simplify the template code when dealing with permissions (which user see which blocks).

@anitanh
Copy link
Contributor Author

anitanh commented Jan 4, 2018

Hi @timlinux , here is update:

  • Added organisation model
  • Added organisation create and list view
  • The existing projects are assigned to default organisation (Kartoza)
  • Added domain model
  • Added domain create and list view
  • Domain list view only available for staff
  • Added domain check middleware
  • Changed nginx conf server name to * (wildcard)
  • When a domain is registered with role as project, the site will point to project page
  • When a domain is registered with role as organisation, the site will point to home page (project list page) with only showing the project in that organisation.
  • Added domain check middleware test
  • Update existing tests

Gifs:

  • Organisation create view
    peek 2018-01-03 17-07

  • Organisation list and pending view
    peek 2018-01-03 17-08

  • Domain create view
    User may click on register a domain from navigation.
    peek 2018-01-03 17-32

Or may click on set up custom domain button on project page
peek 2018-01-03 17-42

  • When domain is not registered or not approved yet
    peek 2018-01-03 17-35

  • Domain list view (only available to staff users)
    peek 2018-01-03 17-36

  • Domain as organisation role
    peek 2018-01-03 17-38

  • Domain as project role
    peek 2018-01-03 17-40

Travis is still failing, I am still investigating it.

@timlinux
Copy link
Contributor

timlinux commented Jan 4, 2018

Wow @Ann26 beautiful work! Please merge when you have travis passing and then deploy it to staging so I can play with it a bit.

@anitanh anitanh merged commit 80759c7 into kartoza:develop Jan 9, 2018
dimasciput added a commit to dimasciput/projecta that referenced this pull request Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

We need an organisation model We need to support user domains
3 participants